# dev.knotless.getBlame

> Published by [lexicons.knotless.dev](https://lexicon.garden/identity/did:plc:yqsg7znbbhfmj3a2nrpnaerk)

✓ This is the authoritative definition for this NSID.

## Description

Who last changed each line of a file at a revision.

## Links

- [View on Lexicon Garden](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.getBlame)
- [Documentation](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.getBlame/docs)
- [Examples](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.getBlame/examples)

## Definitions

### `dev.knotless.getBlame#hunk`

**Type**: `object`

A run of lines one commit last changed.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `count` | `integer` | Yes | How many lines it runs for. |
| `previous` | `ref` → `#previous` | No |  |
| `sha` | `string` | Yes | The commit, in hex: one of `commits`. |
| `start` | `integer` | Yes | The run's first line, counted from 1. |

### `dev.knotless.getBlame`

**Type**: `query`

Who last changed each line of a text file at a revision, as git blame finds it: the file's text, the ranges its highlighting paints, its lines in runs from the same commit, and each of those commits once. A binary file, or one over 256 KiB, is refused. No authentication needed; asked as an account, with a service token or the pages' session cookie, a private repository it is a member of is read too, and the answer is that account's alone.

#### Parameters

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `path` | `string` | No | A file in the tree, from its root. |
| `ref` | `string` | No | A branch, a tag or a commit, which may run on into the path, as dev.knotless.getFile takes it; the default branch if absent. |
| `repo` | `string` (at-uri) | Yes | The repository's dev.knotless.repo record, as dev.knotless.getFile takes it. |

#### Output

**Encoding**: `application/json`

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `commits` | `array` | Yes | Each commit a run names, once. |
| `hunks` | `array` | Yes | Its lines in runs, each last changed by one commit, from the first line on. |
| `lines` | `integer` | Yes | How many lines the text has. |
| `path` | `string` | Yes | The file, from the root. |
| `ranges` | `string` | Yes | The ranges its highlighting paints, encoded as the pages read them, as dev.knotless.getFile has them. |
| `ref` | `string` | Yes | The ref or commit shown, as `ref` named it, less any path. |
| `text` | `string` | Yes | The file's text. |

#### Errors

- **NotFound**: No such repository, revision or file.
- **InvalidRequest**: The file is binary, or too large to blame.

### `dev.knotless.getBlame#previous`

**Type**: `object`

Where blame goes on before the run's commit: its parent, and the file's path there. Absent where the commit made the file.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `path` | `string` | Yes | The file's path in that parent, from the root. |
| `sha` | `string` | Yes | The commit's parent, in hex. |

## Raw Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "hunk": {
      "description": "A run of lines one commit last changed.",
      "properties": {
        "count": {
          "description": "How many lines it runs for.",
          "minimum": 1,
          "type": "integer"
        },
        "previous": {
          "ref": "#previous",
          "type": "ref"
        },
        "sha": {
          "description": "The commit, in hex: one of `commits`.",
          "type": "string"
        },
        "start": {
          "description": "The run's first line, counted from 1.",
          "minimum": 1,
          "type": "integer"
        }
      },
      "required": [
        "sha",
        "start",
        "count"
      ],
      "type": "object"
    },
    "main": {
      "description": "Who last changed each line of a text file at a revision, as git blame finds it: the file's text, the ranges its highlighting paints, its lines in runs from the same commit, and each of those commits once. A binary file, or one over 256 KiB, is refused. No authentication needed; asked as an account, with a service token or the pages' session cookie, a private repository it is a member of is read too, and the answer is that account's alone.",
      "errors": [
        {
          "description": "No such repository, revision or file.",
          "name": "NotFound"
        },
        {
          "description": "The file is binary, or too large to blame.",
          "name": "InvalidRequest"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "commits": {
              "description": "Each commit a run names, once.",
              "items": {
                "ref": "dev.knotless.defs#commitView",
                "type": "ref"
              },
              "type": "array"
            },
            "hunks": {
              "description": "Its lines in runs, each last changed by one commit, from the first line on.",
              "items": {
                "ref": "#hunk",
                "type": "ref"
              },
              "type": "array"
            },
            "lines": {
              "description": "How many lines the text has.",
              "minimum": 1,
              "type": "integer"
            },
            "path": {
              "description": "The file, from the root.",
              "type": "string"
            },
            "ranges": {
              "description": "The ranges its highlighting paints, encoded as the pages read them, as dev.knotless.getFile has them.",
              "type": "string"
            },
            "ref": {
              "description": "The ref or commit shown, as `ref` named it, less any path.",
              "type": "string"
            },
            "text": {
              "description": "The file's text.",
              "type": "string"
            }
          },
          "required": [
            "ref",
            "path",
            "lines",
            "text",
            "ranges",
            "hunks",
            "commits"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "path": {
            "description": "A file in the tree, from its root.",
            "maxLength": 4096,
            "type": "string"
          },
          "ref": {
            "description": "A branch, a tag or a commit, which may run on into the path, as dev.knotless.getFile takes it; the default branch if absent.",
            "maxLength": 1024,
            "type": "string"
          },
          "repo": {
            "description": "The repository's dev.knotless.repo record, as dev.knotless.getFile takes it.",
            "format": "at-uri",
            "type": "string"
          }
        },
        "required": [
          "repo"
        ],
        "type": "params"
      },
      "type": "query"
    },
    "previous": {
      "description": "Where blame goes on before the run's commit: its parent, and the file's path there. Absent where the commit made the file.",
      "properties": {
        "path": {
          "description": "The file's path in that parent, from the root.",
          "type": "string"
        },
        "sha": {
          "description": "The commit's parent, in hex.",
          "type": "string"
        }
      },
      "required": [
        "sha",
        "path"
      ],
      "type": "object"
    }
  },
  "description": "Who last changed each line of a file at a revision.",
  "id": "dev.knotless.getBlame",
  "lexicon": 1
}
```
