Monitors the status of GitHub pull requests. Checks if a pull request is mergable, including the status of reviews, merge conflicts and checks. Initially based off of 'Pull Request Monitor' by Erich Behrens.
Please note this extension is designed for my own use and may change / not work at any time.
Usage
Generate a GitHub token with the public_repo permission at https://github.com/settings/tokens.
(if you wish to monitor private repositories too, include repo)
Open the command palette and execute mitchells-monitor.setToken; after setting your token the extension will start monitoring your pull requests and display them in the status bar.
Colours
The status bar colours each pull request by its status family, using these theme colours. Override them for a theme in workbench.colorCustomizations:
| Theme colour |
Used for |
mitchellsMonitor.mergeable |
Ready to merge |
mitchellsMonitor.merged |
Merged |
mitchellsMonitor.closed |
Closed |
mitchellsMonitor.draft |
Drafts |
mitchellsMonitor.pending |
Checks running |
mitchellsMonitor.attention |
Changes requested, conflicts, failing checks, reviews not satisfied, status unknown |
A colour set for a status in the mitchells-monitor.colors setting still wins over the theme colour, in every theme.
API for other extensions
activate() returns an API, so other extensions (such as Mitchell's Worktrees) can show the pull request of a branch with Monitor's own status, icons and colours, using Monitor's token and settings. Its types ship with the extension as dist/api.d.ts, in the extension's folder (such as ~/.vscode/extensions/commitchell.mitchells-monitor-1.4.0/dist/api.d.ts); copy them into your extension.
const extension = vscode.extensions.getExtension<MitchellsMonitorApi>(
"commitchell.mitchells-monitor",
);
const monitor = extension?.isActive ? extension.exports : await extension?.activate();
if (monitor?.version === 1 && monitor.getState() === "READY") {
const byBranch = await monitor.getPullRequests(
{ owner: "commitchell", name: "mitchells-monitor" },
["develop", "feature/api"],
);
const pr = byBranch.get("feature/api"); // undefined when the branch has no pull request
}
monitor?.onDidChange(() => {
/* read again */
});
getState() is READY when a token is set and the last refresh worked, NO_TOKEN before a token is set, ERROR when the last refresh failed (token not authorised, offline, no VPN) and STOPPED when monitoring is stopped.
getPullRequests(repo, branches) gives the newest pull request (open, merged or closed) whose head is each branch of the repository itself; pull requests from forks are skipped. Branches are fetched in one GraphQL query per repository, then answered from a cache. The branches last asked for in each repository are refreshed on Monitor's refresh interval and the others are forgotten. Asking for a branch that is already being fetched waits for that fetch rather than sending another. It rejects when GitHub cannot be reached.
onDidChange fires after each refresh, when monitoring stops, and when githubEnterpriseUrl, titleRegex or colors change.
Each PullRequestStatus has:
| Field |
Contents |
number, title, url, branch, baseBranch, isDraft |
From GitHub |
label |
What the status bar shows: the titleRegex match or the number |
state |
OPEN, MERGED or CLOSED |
status |
MERGEABLE, MERGED, CLOSED, or the reasons an open pull request cannot be merged in ascending priority; the last one sets the icon and colour |
icon |
The codicon id the status bar uses, without $() |
color |
The theme colour id of the status family |
colorValues |
{ light, dark } as #hex or rgba() colours, for drawing outside the theme (generated SVGs, for one); a mitchells-monitor.colors override is used for both |
checks |
SUCCESS, PENDING, FAILURE or null without checks |
reviewDecision, approvedBy, changesRequestedBy |
GitHub's review decision, and the reviewers whose latest review approved or requested changes |
mergeable |
MERGEABLE, CONFLICTING or UNKNOWN |
mergeCommitIssues |
Always false for now: Monitor does not check the potential merge commit, so MERGE_COMMIT_ISSUES is never among the reasons |
| |