azdiffs 0.1.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/cli.js +124 -54
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ Fast pull request review for Azure DevOps (Azure Repos Git), served from your te
|
|
|
6
6
|
npx azdiffs setup # once: organization, default project, sign-in method
|
|
7
7
|
npx azdiffs # list the pull requests waiting for your review, pick one
|
|
8
8
|
npx azdiffs https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}
|
|
9
|
+
npx azdiffs {repo} {id} # by repository and id
|
|
10
|
+
npx azdiffs {id} # inside a clone of the repository
|
|
9
11
|
```
|
|
10
12
|
|
|
11
13
|
Opening a pull request starts a local server on `http://127.0.0.1:4747` and opens your
|
|
@@ -16,8 +18,13 @@ same server.
|
|
|
16
18
|
|
|
17
19
|
```
|
|
18
20
|
azdiffs [pull-request-url] [options]
|
|
21
|
+
azdiffs [repo] <id> [--org <name>] [--project <name>] [options]
|
|
19
22
|
|
|
20
23
|
pull-request-url Open this pull request directly.
|
|
24
|
+
repo id Open pull request <id> of this repository: in the current clone's
|
|
25
|
+
organization and project, else the default organization and project
|
|
26
|
+
(choose others with --org and --project)
|
|
27
|
+
id Inside an Azure Repos clone: open pull request <id> of that repository
|
|
21
28
|
(no url) List pull requests waiting for your review and pick one.
|
|
22
29
|
|
|
23
30
|
--org <name> Look in this saved organization instead of the default (repeatable)
|
|
@@ -37,9 +44,10 @@ In the picker, arrow keys move, typing filters (title, repository, author or `!i
|
|
|
37
44
|
Enter opens, Esc quits. Piped, or with `--list`, it prints `URL<TAB>title<TAB>author`
|
|
38
45
|
lines instead and starts nothing.
|
|
39
46
|
|
|
40
|
-
Run inside a clone of an Azure Repos repository, `npx azdiffs` lists
|
|
41
|
-
|
|
42
|
-
branch you have checked out
|
|
47
|
+
Run inside a clone of an Azure Repos repository, `npx azdiffs` lists every active pull
|
|
48
|
+
request of that repository in three sections: **This branch** (the pull request of the
|
|
49
|
+
branch you have checked out, even if you wrote it), **Waiting for your review**, and
|
|
50
|
+
**Other pull requests** (newest first; yours are marked `you`).
|
|
43
51
|
The organization, project and repository come from the git remote (the branch's upstream,
|
|
44
52
|
else `origin`); a first run starts setup with them filled in. `--org`, `--project`,
|
|
45
53
|
`--all-projects` and `--no-repo` turn this off. Outside a clone nothing changes.
|
package/dist/cli.js
CHANGED
|
@@ -694,7 +694,7 @@ function azErrorLine(stderr) {
|
|
|
694
694
|
// package.json
|
|
695
695
|
var package_default = {
|
|
696
696
|
name: "azdiffs",
|
|
697
|
-
version: "0.1
|
|
697
|
+
version: "1.0.1",
|
|
698
698
|
description: "Fast pull request review for Azure DevOps, served from your terminal",
|
|
699
699
|
license: "MIT",
|
|
700
700
|
repository: {
|
|
@@ -1579,13 +1579,13 @@ function pullRequestListPath(project, repository) {
|
|
|
1579
1579
|
}
|
|
1580
1580
|
return project === null ? ["_apis", "git", "pullrequests"] : [project, "_apis", "git", "pullrequests"];
|
|
1581
1581
|
}
|
|
1582
|
-
async function listPullRequests(client, params = {}) {
|
|
1583
|
-
return (await listPullRequestPage(client, params)).pullRequests;
|
|
1584
|
-
}
|
|
1585
1582
|
var REVIEWER_PROJECT_CAP = 25, REVIEWER_CONCURRENCY = 4, REVIEWER_PAGE_SIZE = 100, REVIEWER_MAX_PAGES = 10;
|
|
1586
1583
|
async function listPullRequestsForReviewer(client, reviewerId, options = {}) {
|
|
1587
1584
|
return listActivePullRequests(client, { reviewerId }, options);
|
|
1588
1585
|
}
|
|
1586
|
+
async function listAllActivePullRequests(client, options = {}) {
|
|
1587
|
+
return listActivePullRequests(client, {}, options);
|
|
1588
|
+
}
|
|
1589
1589
|
async function listActivePullRequests(client, criteria, { project = null, repository, ...options }) {
|
|
1590
1590
|
let result = (scope, pullRequests) => ({
|
|
1591
1591
|
pullRequests,
|
|
@@ -2727,6 +2727,7 @@ function send(response, status, body) {
|
|
|
2727
2727
|
|
|
2728
2728
|
// src/args.ts
|
|
2729
2729
|
var DEFAULT_PORT = 4747, USAGE = `Usage: azdiffs [pull-request-url] [options]
|
|
2730
|
+
azdiffs [repo] <id> [--org <name>] [--project <name>] [options]
|
|
2730
2731
|
azdiffs setup [--org <name|url>] [--project <name> | --all-projects] [--auth <azure-cli|pat>] [--tenant <t>]
|
|
2731
2732
|
azdiffs config [--remove <org>]
|
|
2732
2733
|
|
|
@@ -2735,8 +2736,13 @@ Review Azure DevOps pull requests in your browser.
|
|
|
2735
2736
|
Arguments:
|
|
2736
2737
|
pull-request-url Open this pull request directly, for example
|
|
2737
2738
|
https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}
|
|
2739
|
+
repo id Open pull request <id> of this repository: in the current clone's
|
|
2740
|
+
organization and project, else the default organization and project
|
|
2741
|
+
(choose others with --org and --project)
|
|
2742
|
+
id Inside an Azure Repos clone: open pull request <id> of that repository
|
|
2738
2743
|
(no url) List pull requests waiting for your review and pick one. Inside an
|
|
2739
|
-
Azure Repos clone: that repository
|
|
2744
|
+
Azure Repos clone: every active pull request of that repository, in
|
|
2745
|
+
sections: this branch, waiting for your review, other pull requests
|
|
2740
2746
|
|
|
2741
2747
|
Options:
|
|
2742
2748
|
--org <name> Look in this saved organization instead of the default (repeatable)
|
|
@@ -2765,7 +2771,7 @@ Commands:
|
|
|
2765
2771
|
|
|
2766
2772
|
Without a terminal (piped output), and with --list, the list is printed one pull request
|
|
2767
2773
|
per line (URL, title, author; tab-separated) and nothing is started.
|
|
2768
|
-
Sign-in uses the method saved by "azdiffs setup", else your Azure CLI session ("az login").`, TENANT_MESSAGE = "--tenant needs a Microsoft Entra tenant: a GUID or a domain such as contoso.onmicrosoft.com.", EXPECTED_URL = "Expected an Azure DevOps pull request URL such as https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}";
|
|
2774
|
+
Sign-in uses the method saved by "azdiffs setup", else your Azure CLI session ("az login").`, TENANT_MESSAGE = "--tenant needs a Microsoft Entra tenant: a GUID or a domain such as contoso.onmicrosoft.com.", EXPECTED_URL = "Expected an Azure DevOps pull request URL such as https://dev.azure.com/{org}/{project}/_git/{repo}/pullrequest/{id}", EXPECTED_TARGET = "Expected a pull request URL, <repo> <id>, or <id>. Run azdiffs --help for usage.", ID_MESSAGE = "A pull request id is a positive whole number, such as 1234.";
|
|
2769
2775
|
function parseArgs(argv) {
|
|
2770
2776
|
if (argv[0] === "setup")
|
|
2771
2777
|
return parseSetup(argv.slice(1));
|
|
@@ -2775,7 +2781,7 @@ function parseArgs(argv) {
|
|
|
2775
2781
|
}
|
|
2776
2782
|
var ORG_MESSAGE = "--org needs an organization: a name, https://dev.azure.com/<name>, or <name>.visualstudio.com.";
|
|
2777
2783
|
function parseServe(argv) {
|
|
2778
|
-
let port = DEFAULT_PORT, open = !0, tenant = null,
|
|
2784
|
+
let port = DEFAULT_PORT, open = !0, tenant = null, positionals = [], organizations = [], projectName = null, allProjects = !1, list = !1, noRepo = !1, web = !1, listOption = null, listOnlyOption = null;
|
|
2779
2785
|
for (let index = 0;index < argv.length; index++) {
|
|
2780
2786
|
let arg = argv[index] ?? "", [flag, inlineValue] = splitInlineValue(arg);
|
|
2781
2787
|
switch (flag) {
|
|
@@ -2820,13 +2826,13 @@ function parseServe(argv) {
|
|
|
2820
2826
|
continue;
|
|
2821
2827
|
}
|
|
2822
2828
|
case "--all-projects":
|
|
2823
|
-
allProjects = !0, listOption ??= flag;
|
|
2829
|
+
allProjects = !0, listOption ??= flag, listOnlyOption ??= flag;
|
|
2824
2830
|
continue;
|
|
2825
2831
|
case "--list":
|
|
2826
|
-
list = !0, listOption ??= flag;
|
|
2832
|
+
list = !0, listOption ??= flag, listOnlyOption ??= flag;
|
|
2827
2833
|
continue;
|
|
2828
2834
|
case "--no-repo":
|
|
2829
|
-
noRepo = !0, listOption ??= flag;
|
|
2835
|
+
noRepo = !0, listOption ??= flag, listOnlyOption ??= flag;
|
|
2830
2836
|
continue;
|
|
2831
2837
|
case "--web":
|
|
2832
2838
|
web = !0;
|
|
@@ -2834,18 +2840,45 @@ function parseServe(argv) {
|
|
|
2834
2840
|
}
|
|
2835
2841
|
if (arg.startsWith("-") && arg !== "-")
|
|
2836
2842
|
return invalid(`Unknown option ${flag}. Run azdiffs --help for usage.`);
|
|
2837
|
-
if (
|
|
2838
|
-
return invalid(
|
|
2839
|
-
|
|
2843
|
+
if (positionals.length === 2)
|
|
2844
|
+
return invalid(EXPECTED_TARGET);
|
|
2845
|
+
positionals.push(arg);
|
|
2840
2846
|
}
|
|
2841
2847
|
if (allProjects && projectName !== null)
|
|
2842
2848
|
return invalid("Choose either --project or --all-projects, not both.");
|
|
2843
|
-
|
|
2849
|
+
let [first, second] = positionals;
|
|
2850
|
+
if (first !== void 0) {
|
|
2844
2851
|
if (web)
|
|
2845
|
-
return invalid("--web opens the home page; it does not take a pull request
|
|
2852
|
+
return invalid("--web opens the home page; it does not take a pull request.");
|
|
2853
|
+
let id = parsePullRequestId(second ?? first);
|
|
2854
|
+
if (second !== void 0 || id !== null) {
|
|
2855
|
+
let repository = second === void 0 ? null : first;
|
|
2856
|
+
if (repository !== null && !isRepositoryName(repository))
|
|
2857
|
+
return invalid(EXPECTED_TARGET);
|
|
2858
|
+
if (id === null)
|
|
2859
|
+
return invalid(ID_MESSAGE);
|
|
2860
|
+
if (repository === null && listOption !== null)
|
|
2861
|
+
return invalid(`${listOption} does not apply to azdiffs <id>, which opens a pull request of the current clone.`);
|
|
2862
|
+
if (listOnlyOption !== null)
|
|
2863
|
+
return invalid(`${listOnlyOption} applies to the pull request list, not to <repo> <id>.`);
|
|
2864
|
+
if (organizations.length > 1)
|
|
2865
|
+
return invalid("Give at most one --org with <repo> <id>.");
|
|
2866
|
+
return {
|
|
2867
|
+
kind: "serve-id",
|
|
2868
|
+
options: {
|
|
2869
|
+
port,
|
|
2870
|
+
open,
|
|
2871
|
+
tenant,
|
|
2872
|
+
repository,
|
|
2873
|
+
pullRequestId: id,
|
|
2874
|
+
organization: organizations[0] ?? null,
|
|
2875
|
+
project: projectName
|
|
2876
|
+
}
|
|
2877
|
+
};
|
|
2878
|
+
}
|
|
2846
2879
|
if (listOption !== null)
|
|
2847
2880
|
return invalid(`${listOption} applies to the pull request list, not to a pull request URL.`);
|
|
2848
|
-
let pullRequest = parsePullRequestUrl(
|
|
2881
|
+
let pullRequest = parsePullRequestUrl(first);
|
|
2849
2882
|
if (pullRequest === null)
|
|
2850
2883
|
return invalid(`${EXPECTED_URL}.`);
|
|
2851
2884
|
return { kind: "serve", options: { port, open, pullRequest, tenant } };
|
|
@@ -2945,6 +2978,15 @@ function splitInlineValue(arg) {
|
|
|
2945
2978
|
let equals = arg.indexOf("=");
|
|
2946
2979
|
return equals === -1 ? [arg, void 0] : [arg.slice(0, equals), arg.slice(equals + 1)];
|
|
2947
2980
|
}
|
|
2981
|
+
function parsePullRequestId(value) {
|
|
2982
|
+
if (!/^[0-9]+$/.test(value))
|
|
2983
|
+
return null;
|
|
2984
|
+
let id = Number(value);
|
|
2985
|
+
return Number.isSafeInteger(id) && id > 0 ? id : null;
|
|
2986
|
+
}
|
|
2987
|
+
function isRepositoryName(value) {
|
|
2988
|
+
return value.trim().length > 0 && !/[/\\]/.test(value) && !value.includes("://");
|
|
2989
|
+
}
|
|
2948
2990
|
function parsePort(value) {
|
|
2949
2991
|
if (!/^[0-9]+$/.test(value))
|
|
2950
2992
|
return null;
|
|
@@ -3442,7 +3484,7 @@ function defaultRow(item) {
|
|
|
3442
3484
|
return item.hint === void 0 ? label : `${label} ${sanitizeTerminalText(item.hint)}`;
|
|
3443
3485
|
}
|
|
3444
3486
|
function selectInteraction(options) {
|
|
3445
|
-
let pageSize = Math.max(1, options.pageSize ?? DEFAULT_PAGE_SIZE), filtering = options.filter === !0, matches = options.matches ?? defaultMatches, renderRow = options.renderRow ?? defaultRow, footer = options.footer ?? (filtering ? "↑↓ move · type to filter · enter select · esc cancel" : "↑↓ move · enter select · esc cancel"), query = "", visible = options.items, active = initialIndex(), offset = 0;
|
|
3487
|
+
let pageSize = Math.max(1, options.pageSize ?? DEFAULT_PAGE_SIZE), filtering = options.filter === !0, matches = options.matches ?? defaultMatches, renderRow = options.renderRow ?? defaultRow, renderGroup = options.renderGroup ?? ((group) => sanitizeTerminalText(group)), footer = options.footer ?? (filtering ? "↑↓ move · type to filter · enter select · esc cancel" : "↑↓ move · enter select · esc cancel"), query = "", visible = options.items, active = initialIndex(), offset = 0;
|
|
3446
3488
|
function initialIndex() {
|
|
3447
3489
|
let { initial } = options;
|
|
3448
3490
|
if (typeof initial === "number")
|
|
@@ -3476,6 +3518,8 @@ function selectInteraction(options) {
|
|
|
3476
3518
|
let position = offset + index;
|
|
3477
3519
|
if (item.separatorBefore === !0 && position > 0)
|
|
3478
3520
|
rows.push(`${INACTIVE_MARKER}${SEPARATOR.repeat(rowWidth)}`);
|
|
3521
|
+
if (item.group !== void 0 && (index === 0 || visible[position - 1]?.group !== item.group))
|
|
3522
|
+
rows.push(renderGroup(item.group, rowWidth + ACTIVE_MARKER.length));
|
|
3479
3523
|
let isActive = position === active, marker = isActive ? ACTIVE_MARKER : INACTIVE_MARKER;
|
|
3480
3524
|
rows.push(`${marker}${renderRow(item, { active: isActive, width: rowWidth })}`);
|
|
3481
3525
|
}), rows.length === 0)
|
|
@@ -3617,7 +3661,11 @@ function formatRow(item, width, layout, style = { color: !1 }) {
|
|
|
3617
3661
|
}
|
|
3618
3662
|
|
|
3619
3663
|
// src/picker/picker.ts
|
|
3620
|
-
var HOME_LABEL = "Open azdiffs in the browser",
|
|
3664
|
+
var HOME_LABEL = "Open azdiffs in the browser", SECTION_HEADINGS = {
|
|
3665
|
+
branch: "This branch",
|
|
3666
|
+
review: "Waiting for your review",
|
|
3667
|
+
other: "Other pull requests"
|
|
3668
|
+
}, PICKER_FOOTER = "↑↓ move · type to filter · enter open · esc quit";
|
|
3621
3669
|
function pickerMessage(count, repository = null) {
|
|
3622
3670
|
return repository === null ? `Pull requests waiting for your review (${count})` : `Pull requests in ${sanitizeTerminalText(repository)} (${count})`;
|
|
3623
3671
|
}
|
|
@@ -3636,7 +3684,8 @@ async function runPicker(options) {
|
|
|
3636
3684
|
separatorBefore: !0
|
|
3637
3685
|
}, rows = items.map((item) => ({
|
|
3638
3686
|
value: { kind: "open", item },
|
|
3639
|
-
label: sanitizeTerminalText(item.entry.pullRequest.title)
|
|
3687
|
+
label: sanitizeTerminalText(item.entry.pullRequest.title),
|
|
3688
|
+
...item.section === void 0 ? {} : { group: SECTION_HEADINGS[item.section] }
|
|
3640
3689
|
}));
|
|
3641
3690
|
try {
|
|
3642
3691
|
return await promptSelect(options, {
|
|
@@ -3645,6 +3694,10 @@ async function runPicker(options) {
|
|
|
3645
3694
|
filter: !0,
|
|
3646
3695
|
footer: PICKER_FOOTER,
|
|
3647
3696
|
notes: (options.notes ?? []).map(sanitizeTerminalText),
|
|
3697
|
+
renderGroup: (group, width) => {
|
|
3698
|
+
let heading = truncateToWidth(group, width);
|
|
3699
|
+
return style.color ? `\x1B[1m${heading}\x1B[0m` : heading;
|
|
3700
|
+
},
|
|
3648
3701
|
renderRow: (row, { width }) => row.value.kind === "home" ? HOME_LABEL : formatRow(row.value.item, width, layout, style),
|
|
3649
3702
|
matches: (row, query) => row.value.kind === "open" && matchesQuery(row.value.item, query, showOrganization),
|
|
3650
3703
|
summary: (row) => {
|
|
@@ -3799,54 +3852,53 @@ function repositoryTarget(settings, { remote, branch }) {
|
|
|
3799
3852
|
var ORGANIZATION_CONCURRENCY = 4;
|
|
3800
3853
|
async function loadReviewQueue(options) {
|
|
3801
3854
|
let settled = await mapWithConcurrency(options.targets, options.concurrency ?? ORGANIZATION_CONCURRENCY, async (target) => {
|
|
3802
|
-
let client = options.getClient(target.organization), user = await getAuthenticatedUser(client)
|
|
3855
|
+
let client = options.getClient(target.organization), user = await getAuthenticatedUser(client);
|
|
3856
|
+
return { listed: target.repository === null ? await listPullRequestsForReviewer(client, user.id, { project: target.project }) : await listAllActivePullRequests(client, {
|
|
3803
3857
|
project: target.project,
|
|
3804
|
-
|
|
3805
|
-
});
|
|
3806
|
-
|
|
3807
|
-
listed,
|
|
3808
|
-
queue: toReviewQueue(listed.pullRequests, user.id),
|
|
3809
|
-
branch: await branch,
|
|
3810
|
-
userId: user.id
|
|
3811
|
-
};
|
|
3812
|
-
}), branchItems = [], queueItems = [], failures = [], notes = [];
|
|
3858
|
+
repository: target.repository
|
|
3859
|
+
}), userId: user.id };
|
|
3860
|
+
}), branchItems = [], queueItems = [], otherItems = [], failures = [], notes = [];
|
|
3813
3861
|
settled.forEach((outcome, index) => {
|
|
3814
3862
|
let target = options.targets[index], { organization } = target;
|
|
3815
3863
|
if (outcome.status === "rejected") {
|
|
3816
3864
|
failures.push({ organization, reason: failureReason(outcome.reason, target) });
|
|
3817
3865
|
return;
|
|
3818
3866
|
}
|
|
3819
|
-
let { listed,
|
|
3820
|
-
if (queueItems.push(...queue.map((entry) => ({ organization, entry }))),
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3867
|
+
let { listed, userId } = outcome.value, inRepository = target.repository !== null, sectioned = (item, section) => inRepository ? { ...item, section } : item, queue = toReviewQueue(listed.pullRequests, userId);
|
|
3868
|
+
if (queueItems.push(...queue.map((entry) => sectioned({ organization, entry }, "review"))), inRepository) {
|
|
3869
|
+
let sourceRef = target.branch === null ? null : `refs/heads/${target.branch}`, queued = new Set(queue.map((entry) => entry.pullRequest));
|
|
3870
|
+
for (let pullRequest of listed.pullRequests) {
|
|
3871
|
+
let fromBranch = pullRequest.sourceRefName === sourceRef;
|
|
3872
|
+
if (!fromBranch && queued.has(pullRequest))
|
|
3873
|
+
continue;
|
|
3874
|
+
let item = {
|
|
3875
|
+
organization,
|
|
3876
|
+
entry: ownEntry(pullRequest, userId),
|
|
3877
|
+
authoredByMe: sameId(pullRequest.author.id, userId),
|
|
3878
|
+
...fromBranch ? { currentBranch: !0 } : {}
|
|
3879
|
+
};
|
|
3880
|
+
if (fromBranch)
|
|
3881
|
+
branchItems.push(sectioned(item, "branch"));
|
|
3882
|
+
else
|
|
3883
|
+
otherItems.push(sectioned(item, "other"));
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3829
3886
|
if (listed.capped)
|
|
3830
3887
|
notes.push(`${organization}: searched the first ${listed.projectsSearched} of ${listed.projectsTotal} projects. Choose one with --project <name>.`);
|
|
3831
3888
|
if (listed.failedProjects.length > 0) {
|
|
3832
3889
|
let names = listed.failedProjects.map(sanitizeTerminalText).join(", ");
|
|
3833
3890
|
notes.push(`${organization}: could not load these projects: ${names}`);
|
|
3834
3891
|
}
|
|
3835
|
-
}), branchItems.sort((a, b) => newestFirst(a.entry.pullRequest, b.entry.pullRequest)), queueItems.sort((a, b) => compareReviewQueueEntries(a.entry, b.entry));
|
|
3836
|
-
let
|
|
3837
|
-
return { items: [...branchItems, ...queueItems.filter((item) =>
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
return
|
|
3842
|
-
|
|
3843
|
-
project,
|
|
3844
|
-
repository,
|
|
3845
|
-
status: "active",
|
|
3846
|
-
sourceRefName: `refs/heads/${branch}`
|
|
3847
|
-
});
|
|
3892
|
+
}), branchItems.sort((a, b) => newestFirst(a.entry.pullRequest, b.entry.pullRequest)), queueItems.sort((a, b) => compareReviewQueueEntries(a.entry, b.entry)), otherItems.sort((a, b) => newestFirst(a.entry.pullRequest, b.entry.pullRequest));
|
|
3893
|
+
let seen = /* @__PURE__ */ new Set;
|
|
3894
|
+
return { items: [...branchItems, ...queueItems, ...otherItems].filter((item) => {
|
|
3895
|
+
let key = itemKey(item);
|
|
3896
|
+
if (seen.has(key))
|
|
3897
|
+
return !1;
|
|
3898
|
+
return seen.add(key), !0;
|
|
3899
|
+
}), failures, notes };
|
|
3848
3900
|
}
|
|
3849
|
-
function
|
|
3901
|
+
function ownEntry(pullRequest, userId) {
|
|
3850
3902
|
let reviewer = pullRequest.reviewers.find((candidate) => sameId(candidate.id, userId)), vote = reviewer?.vote ?? 0;
|
|
3851
3903
|
return { pullRequest, vote, group: reviewGroup(vote), isRequired: reviewer?.isRequired ?? !1 };
|
|
3852
3904
|
}
|
|
@@ -4467,6 +4519,8 @@ async function run(argv, deps) {
|
|
|
4467
4519
|
return exit(await runConfig(command.remove, { ...deps, store: deps.settings }));
|
|
4468
4520
|
case "serve":
|
|
4469
4521
|
return serve(command.options, deps);
|
|
4522
|
+
case "serve-id":
|
|
4523
|
+
return serveById(command.options, deps);
|
|
4470
4524
|
case "pick":
|
|
4471
4525
|
return pick(command.options, deps);
|
|
4472
4526
|
}
|
|
@@ -4530,6 +4584,22 @@ async function serve(options, deps) {
|
|
|
4530
4584
|
return session;
|
|
4531
4585
|
return openPage(options, deps, session);
|
|
4532
4586
|
}
|
|
4587
|
+
async function serveById(options, deps) {
|
|
4588
|
+
let remote = (await deps.readRepository?.() ?? null)?.remote ?? null, repository = options.repository ?? remote?.repository;
|
|
4589
|
+
if (repository === void 0)
|
|
4590
|
+
return deps.stderr("azdiffs <id> works inside a clone of an Azure Repos repository. Elsewhere, run: npx azdiffs <repo> <id>"), exit(1);
|
|
4591
|
+
let knowsOrganization = options.organization !== null || remote !== null, session = await startSession(options.tenant, deps, !knowsOrganization);
|
|
4592
|
+
if (!isSession(session))
|
|
4593
|
+
return session;
|
|
4594
|
+
let { settings } = session, organization = options.organization ?? remote?.organization ?? settings.defaultOrganization ?? [...settings.organizations.keys()].sort()[0] ?? null;
|
|
4595
|
+
if (organization === null)
|
|
4596
|
+
return deps.stderr("Run: npx azdiffs setup"), exit(1);
|
|
4597
|
+
let sameAsClone = remote !== null && remote.organization === organization, project = options.project ?? (sameAsClone ? remote.project : null) ?? findOrganization(settings, organization)?.project ?? null;
|
|
4598
|
+
if (project === null)
|
|
4599
|
+
return deps.stderr(`Which project is ${sanitizeTerminalText(repository)} in? Run: npx azdiffs ${shellWord(repository)} ${options.pullRequestId} --project <name>, or save a default project with npx azdiffs setup --org ${organization}`), exit(1);
|
|
4600
|
+
let pullRequest = { organization, project, repository, pullRequestId: options.pullRequestId }, { port, open, tenant } = options;
|
|
4601
|
+
return openPage({ port, open, tenant, pullRequest }, deps, session);
|
|
4602
|
+
}
|
|
4533
4603
|
async function pick(options, deps) {
|
|
4534
4604
|
let context = options.useRepository ? await deps.readRepository?.() ?? null : null, session = await startSession(options.tenant, deps, !0, context?.remote ?? null);
|
|
4535
4605
|
if (!isSession(session))
|
|
@@ -4571,7 +4641,7 @@ async function pick(options, deps) {
|
|
|
4571
4641
|
if (repository === null)
|
|
4572
4642
|
say("Nothing is waiting for your review."), say("Open a pull request directly: npx azdiffs <url>");
|
|
4573
4643
|
else
|
|
4574
|
-
say(`
|
|
4644
|
+
say(`No active pull requests in ${sanitizeTerminalText(repository)}.`), say("Run npx azdiffs --no-repo to see your reviews in every repository.");
|
|
4575
4645
|
return exit(0);
|
|
4576
4646
|
}
|
|
4577
4647
|
if (terminal === null) {
|