# dev.knotless.getMergeStatus

> Whether an open pull can merge now, decided as `knotless pull merge` decides it, without merging: whether its head merges with its target branch as it is now, and, in a repository that names runners, whether each workflow that runs on it passed there. And what the account asking may do to it: merge it, queue it, retarget it or run its checks again. Requires the session cookie the pages' login sets, or a service token from the caller's PDS, audience the appview's DID, for this method.

- Kind: query
- Authority: knotless.dev
- Lexicon: 1
- Published by [lexicons.knotless.dev](https://lexicon.garden/identity/did:plc:yqsg7znbbhfmj3a2nrpnaerk), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.getMergeStatus)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.getMergeStatus/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:yqsg7znbbhfmj3a2nrpnaerk/dev.knotless.getMergeStatus/analytics)

## Query (`dev.knotless.getMergeStatus`)

Type: query · GET

### Parameters (query string)

- `pull` (string · at-uri, required): The dev.knotless.pull record.
- `repo` (string · at-uri, required): The repository's dev.knotless.repo record, as dev.knotless.getRepo takes it.

### Output (application/json)

- `autoMerge` (ref)
  - Reference: `#autoMerge`
- `base` (string, required): The commit its target branch is at, in hex.
- `checks` (string, required): Where its checks stand at its head merged with its base: pending for those not run there; none when the repository names no runners, so a merge waits for none, or when it conflicts.
  - Constraints: knownValues: passed | failed | running | pending | none
- `codeOwnersWarnings` (array): The lines of the target branch's CODEOWNERS file that were skipped, and why: one naming a team, say.
  - `items` (ref)
    - Reference: `#note`
- `conflicts` (array): The files that conflict.
  - `items` (ref)
    - Reference: `#conflict`
- `deletes` (string): Its head branch, which merging deletes unless asked to keep it.
- `head` (string, required): The commit its head branch is at, in hex.
- `may` (ref, required)
  - Reference: `#permissions`
- `method` (string, required): How it would merge: a merge commit naming the pull; into a branch protected as linear, one squashed commit. fastForward is no longer made.
  - Constraints: knownValues: fastForward | merge | squash
- `queueBlocked` (string): Why the merge queue would not land it yet, when this server knows: undelegated when no runner the repository names may push, so its queue lands through this server's gateway, and the owner has not delegated writes to it.
  - Constraints: knownValues: undelegated
- `queueOnly` (boolean): Its target branch takes pulls only through the merge queue: queue it with dev.knotless.queuePull, as dev.knotless.mergePull refuses it. Absent is false.
- `reason` (string): Why it cannot merge now, in the words a merge would refuse it with; and when the account asking may not merge it, that too.
- `reviews` (string): Where its reviews stand against what its target branch's rule asks of them (dev.knotless.repo#reviews): none when the rule asks nothing of them, or when it conflicts.
  - Constraints: knownValues: passed | blocked | none
- `reviewsMissing` (array): What its reviews lack, each as `knotless pull merge --check` lists it: `reviews 1 of 2`, `owners of web/: @alice or @bob`, `changes asked by @carol`.
  - `items` (ref)
    - Reference: `#note`
- `reviewsUncounted` (array): The approvals that do not count toward its target branch's rule, and why: `@dan's approval does not count: only the owner's and collaborators' approvals count`, or one of an earlier head when only approvals of its head as it is now count.
  - `items` (ref)
    - Reference: `#note`
- `state` (string, required): clean when it can merge now; conflicting when its head does not merge with its base; blocked when its checks have not all passed, or it is not reviewed as its target branch's rule asks; draft, whatever else holds, while its author has not marked it ready.
  - Constraints: knownValues: clean | conflicting | blocked | draft

### Errors

- `NotFound`: No such repository.
- `AuthenticationRequired`: No one asked: log in to the pages first.

## #autoMerge (`dev.knotless.getMergeStatus#autoMerge`)

Type: object

Where the pull's merge when checks pass stands, if it was ever set and not cancelled by someone: a runner the repository names merges it once it would merge.

### Properties

- `by` (ref, required): Who set it.
  - Reference: `dev.knotless.defs#actorView`
- `pushedBy` (ref): For pushed, the owner of the head repository pushed to.
  - Reference: `dev.knotless.defs#actorView`
- `state` (string, required): set while it stands; pushed once someone who may not merge it pushed to its head since, and retargeted once it moved to another branch, either of which cancels it.
  - Constraints: knownValues: set | pushed | retargeted

## #conflict (`dev.knotless.getMergeStatus#conflict`)

Type: object

A file that both sides changed so that they do not merge.

### Properties

- `path` (string, required): From the repository's root.

## #note (`dev.knotless.getMergeStatus#note`)

Type: object

A line of text about the pull's reviews.

### Properties

- `text` (string, required): In plain words.

## #permissions (`dev.knotless.getMergeStatus#permissions`)

Type: object

What the account asking may do to the pull: what its part in the repository lets it do, not whether that would work now. state and reason say that: a merge refuses a blocked pull, the owner's merge too, unless the owner forces it.

### Properties

- `autoMerge` (boolean): Set it to merge by itself once its checks pass, with dev.knotless.setAutoMerge: those who may merge it, in a repository that names runners, into a branch with no merge queue. Cancelling that, those and its author may. Absent is false.
- `base` (boolean, required): Change its target branch: those who may close it.
- `force` (boolean, required): Merge it past its checks: the owner alone.
- `head` (boolean, required): Change its head branch: its author.
- `merge` (boolean, required): Merge it: the owner and collaborators.
- `queue` (boolean, required): Put it in the merge queue or take it out: those who may merge it, in a repository whose runners land a queue, while the branch it lands on takes pulls through the queue or it is already queued.
- `rerun` (boolean, required): Ask the runners to run its checks again: the owner, in a repository that names runners.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "autoMerge": {
      "description": "Where the pull's merge when checks pass stands, if it was ever set and not cancelled by someone: a runner the repository names merges it once it would merge.",
      "properties": {
        "by": {
          "description": "Who set it.",
          "ref": "dev.knotless.defs#actorView",
          "type": "ref"
        },
        "pushedBy": {
          "description": "For pushed, the owner of the head repository pushed to.",
          "ref": "dev.knotless.defs#actorView",
          "type": "ref"
        },
        "state": {
          "description": "set while it stands; pushed once someone who may not merge it pushed to its head since, and retargeted once it moved to another branch, either of which cancels it.",
          "knownValues": [
            "set",
            "pushed",
            "retargeted"
          ],
          "type": "string"
        }
      },
      "required": [
        "state",
        "by"
      ],
      "type": "object"
    },
    "conflict": {
      "description": "A file that both sides changed so that they do not merge.",
      "properties": {
        "path": {
          "description": "From the repository's root.",
          "type": "string"
        }
      },
      "required": [
        "path"
      ],
      "type": "object"
    },
    "main": {
      "description": "Whether an open pull can merge now, decided as `knotless pull merge` decides it, without merging: whether its head merges with its target branch as it is now, and, in a repository that names runners, whether each workflow that runs on it passed there. And what the account asking may do to it: merge it, queue it, retarget it or run its checks again. Requires the session cookie the pages' login sets, or a service token from the caller's PDS, audience the appview's DID, for this method.",
      "errors": [
        {
          "description": "No such repository.",
          "name": "NotFound"
        },
        {
          "description": "No one asked: log in to the pages first.",
          "name": "AuthenticationRequired"
        }
      ],
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "autoMerge": {
              "ref": "#autoMerge",
              "type": "ref"
            },
            "base": {
              "description": "The commit its target branch is at, in hex.",
              "type": "string"
            },
            "checks": {
              "description": "Where its checks stand at its head merged with its base: pending for those not run there; none when the repository names no runners, so a merge waits for none, or when it conflicts.",
              "knownValues": [
                "passed",
                "failed",
                "running",
                "pending",
                "none"
              ],
              "type": "string"
            },
            "codeOwnersWarnings": {
              "description": "The lines of the target branch's CODEOWNERS file that were skipped, and why: one naming a team, say.",
              "items": {
                "ref": "#note",
                "type": "ref"
              },
              "type": "array"
            },
            "conflicts": {
              "description": "The files that conflict.",
              "items": {
                "ref": "#conflict",
                "type": "ref"
              },
              "type": "array"
            },
            "deletes": {
              "description": "Its head branch, which merging deletes unless asked to keep it.",
              "type": "string"
            },
            "head": {
              "description": "The commit its head branch is at, in hex.",
              "type": "string"
            },
            "may": {
              "ref": "#permissions",
              "type": "ref"
            },
            "method": {
              "description": "How it would merge: a merge commit naming the pull; into a branch protected as linear, one squashed commit. fastForward is no longer made.",
              "knownValues": [
                "fastForward",
                "merge",
                "squash"
              ],
              "type": "string"
            },
            "queueBlocked": {
              "description": "Why the merge queue would not land it yet, when this server knows: undelegated when no runner the repository names may push, so its queue lands through this server's gateway, and the owner has not delegated writes to it.",
              "knownValues": [
                "undelegated"
              ],
              "type": "string"
            },
            "queueOnly": {
              "description": "Its target branch takes pulls only through the merge queue: queue it with dev.knotless.queuePull, as dev.knotless.mergePull refuses it. Absent is false.",
              "type": "boolean"
            },
            "reason": {
              "description": "Why it cannot merge now, in the words a merge would refuse it with; and when the account asking may not merge it, that too.",
              "type": "string"
            },
            "reviews": {
              "description": "Where its reviews stand against what its target branch's rule asks of them (dev.knotless.repo#reviews): none when the rule asks nothing of them, or when it conflicts.",
              "knownValues": [
                "passed",
                "blocked",
                "none"
              ],
              "type": "string"
            },
            "reviewsMissing": {
              "description": "What its reviews lack, each as `knotless pull merge --check` lists it: `reviews 1 of 2`, `owners of web/: @alice or @bob`, `changes asked by @carol`.",
              "items": {
                "ref": "#note",
                "type": "ref"
              },
              "type": "array"
            },
            "reviewsUncounted": {
              "description": "The approvals that do not count toward its target branch's rule, and why: `@dan's approval does not count: only the owner's and collaborators' approvals count`, or one of an earlier head when only approvals of its head as it is now count.",
              "items": {
                "ref": "#note",
                "type": "ref"
              },
              "type": "array"
            },
            "state": {
              "description": "clean when it can merge now; conflicting when its head does not merge with its base; blocked when its checks have not all passed, or it is not reviewed as its target branch's rule asks; draft, whatever else holds, while its author has not marked it ready.",
              "knownValues": [
                "clean",
                "conflicting",
                "blocked",
                "draft"
              ],
              "type": "string"
            }
          },
          "required": [
            "state",
            "checks",
            "method",
            "base",
            "head",
            "may"
          ],
          "type": "object"
        }
      },
      "parameters": {
        "properties": {
          "pull": {
            "description": "The dev.knotless.pull record.",
            "format": "at-uri",
            "type": "string"
          },
          "repo": {
            "description": "The repository's dev.knotless.repo record, as dev.knotless.getRepo takes it.",
            "format": "at-uri",
            "type": "string"
          }
        },
        "required": [
          "repo",
          "pull"
        ],
        "type": "params"
      },
      "type": "query"
    },
    "note": {
      "description": "A line of text about the pull's reviews.",
      "properties": {
        "text": {
          "description": "In plain words.",
          "type": "string"
        }
      },
      "required": [
        "text"
      ],
      "type": "object"
    },
    "permissions": {
      "description": "What the account asking may do to the pull: what its part in the repository lets it do, not whether that would work now. state and reason say that: a merge refuses a blocked pull, the owner's merge too, unless the owner forces it.",
      "properties": {
        "autoMerge": {
          "description": "Set it to merge by itself once its checks pass, with dev.knotless.setAutoMerge: those who may merge it, in a repository that names runners, into a branch with no merge queue. Cancelling that, those and its author may. Absent is false.",
          "type": "boolean"
        },
        "base": {
          "description": "Change its target branch: those who may close it.",
          "type": "boolean"
        },
        "force": {
          "description": "Merge it past its checks: the owner alone.",
          "type": "boolean"
        },
        "head": {
          "description": "Change its head branch: its author.",
          "type": "boolean"
        },
        "merge": {
          "description": "Merge it: the owner and collaborators.",
          "type": "boolean"
        },
        "queue": {
          "description": "Put it in the merge queue or take it out: those who may merge it, in a repository whose runners land a queue, while the branch it lands on takes pulls through the queue or it is already queued.",
          "type": "boolean"
        },
        "rerun": {
          "description": "Ask the runners to run its checks again: the owner, in a repository that names runners.",
          "type": "boolean"
        }
      },
      "required": [
        "merge",
        "force",
        "queue",
        "base",
        "head",
        "rerun"
      ],
      "type": "object"
    }
  },
  "description": "Whether an open pull can merge now, and what the account asking may do to it.",
  "id": "dev.knotless.getMergeStatus",
  "lexicon": 1
}
```
