bdy 1.25.37-dev → 1.25.38-dev-pr
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/distTs/package.json +2 -1
- package/distTs/src/agent/agent.js +65 -6
- package/distTs/src/api/client.js +191 -1
- package/distTs/src/autocomplete.js +90 -0
- package/distTs/src/cliError.js +5 -0
- package/distTs/src/cliIndex.js +3 -0
- package/distTs/src/command/artifact/downloadDir.js +110 -0
- package/distTs/src/command/autocomplete/install.js +16 -0
- package/distTs/src/command/autocomplete/uninstall.js +16 -0
- package/distTs/src/command/autocomplete.js +14 -0
- package/distTs/src/command/environment/resolve.js +39 -0
- package/distTs/src/command/login.js +1 -1
- package/distTs/src/command/package/create.js +64 -0
- package/distTs/src/command/package/delete.js +38 -0
- package/distTs/src/command/package/docker/login.js +26 -0
- package/distTs/src/command/package/docker.js +11 -0
- package/distTs/src/command/package/download.js +138 -0
- package/distTs/src/command/package/get.js +36 -0
- package/distTs/src/command/package/list.js +31 -0
- package/distTs/src/command/package/publish.js +241 -0
- package/distTs/src/command/package/version/delete.js +39 -0
- package/distTs/src/command/package/version/get.js +45 -0
- package/distTs/src/command/package/version/list.js +47 -0
- package/distTs/src/command/package/version.js +16 -0
- package/distTs/src/command/package.js +26 -0
- package/distTs/src/command/pipeline/run/apply.js +62 -0
- package/distTs/src/command/pr/comment/add.js +66 -0
- package/distTs/src/command/pr/comment/list.js +169 -0
- package/distTs/src/command/pr/comment/status.js +48 -0
- package/distTs/src/command/pr/comment.js +19 -0
- package/distTs/src/command/pr/create.js +43 -0
- package/distTs/src/command/pr/diff.js +227 -0
- package/distTs/src/command/pr/file/list.js +124 -0
- package/distTs/src/command/pr/file/mark.js +45 -0
- package/distTs/src/command/pr/file.js +16 -0
- package/distTs/src/command/pr/get.js +29 -0
- package/distTs/src/command/pr/list.js +79 -0
- package/distTs/src/command/pr/merge.js +66 -0
- package/distTs/src/command/pr/review/request.js +29 -0
- package/distTs/src/command/pr/review/start.js +29 -0
- package/distTs/src/command/pr/review/verdict.js +81 -0
- package/distTs/src/command/pr/review.js +18 -0
- package/distTs/src/command/pr/shared.js +595 -0
- package/distTs/src/command/pr/state.js +38 -0
- package/distTs/src/command/pr/summary.js +316 -0
- package/distTs/src/command/pr/update.js +54 -0
- package/distTs/src/command/pr/updateBranch.js +22 -0
- package/distTs/src/command/pr/versions.js +42 -0
- package/distTs/src/command/pr.js +39 -0
- package/distTs/src/command/scrape/validation.js +154 -0
- package/distTs/src/command/scrape.js +144 -0
- package/distTs/src/command/suiteLink.js +14 -0
- package/distTs/src/command/tests/visual/result/download.js +31 -0
- package/distTs/src/command/tests/visual/result/get.js +68 -0
- package/distTs/src/command/tests/visual/result/list.js +49 -0
- package/distTs/src/command/tests/visual/result.js +23 -0
- package/distTs/src/command/tests/visual/session/get.js +70 -0
- package/distTs/src/command/tests/visual/session/list.js +69 -0
- package/distTs/src/command/tests/visual/session/open.js +22 -0
- package/distTs/src/command/tests/visual/session/reviewUrl.js +37 -0
- package/distTs/src/command/tests/visual/session/update.js +26 -0
- package/distTs/src/command/tests/visual/shared/context.js +144 -0
- package/distTs/src/command/tests/visual/shared/diffRegions.js +172 -0
- package/distTs/src/command/tests/visual/shared/format.js +21 -0
- package/distTs/src/command/tests/visual/shared/lookup.js +107 -0
- package/distTs/src/command/tests/visual/shared/options.js +90 -0
- package/distTs/src/command/tests/visual/shared/review.js +146 -0
- package/distTs/src/command/tests/visual/shared/reviewUrl.js +62 -0
- package/distTs/src/command/tests/visual/shared/session.js +217 -0
- package/distTs/src/command/tests/visual/snapshot/get.js +46 -0
- package/distTs/src/command/tests/visual/snapshot/list.js +68 -0
- package/distTs/src/command/tests/visual/snapshot/open.js +26 -0
- package/distTs/src/command/tests/visual/snapshot/reviewUrl.js +48 -0
- package/distTs/src/command/tests/visual/snapshot.js +28 -0
- package/distTs/src/command/tests/visual/suite/create.js +38 -0
- package/distTs/src/command/tests/visual/suite/delete.js +29 -0
- package/distTs/src/command/tests/visual/suite/get.js +43 -0
- package/distTs/src/command/tests/visual/suite/list.js +35 -0
- package/distTs/src/command/tests/visual/suite/open.js +20 -0
- package/distTs/src/command/tests/visual/suite/update.js +47 -0
- package/distTs/src/command/tests/visual/suite.js +30 -0
- package/distTs/src/command/tunnel/http.js +1 -1
- package/distTs/src/command/tunnel/start.js +1 -1
- package/distTs/src/command/tunnel/tcp.js +1 -1
- package/distTs/src/command/tunnel/tls.js +1 -1
- package/distTs/src/command/ut/upload.js +86 -0
- package/distTs/src/command/ut.js +12 -0
- package/distTs/src/command/vt/close.js +27 -0
- package/distTs/src/command/vt/compare/validation.js +46 -0
- package/distTs/src/command/vt/compare.js +100 -0
- package/distTs/src/command/vt/exec.js +82 -0
- package/distTs/src/command/vt/installBrowser.js +20 -0
- package/distTs/src/command/vt/shared/validation.js +145 -0
- package/distTs/src/command/vt/storybook.js +138 -0
- package/distTs/src/command/vt.js +20 -0
- package/distTs/src/command/yaml/agents.js +88 -0
- package/distTs/src/command/yaml/init.js +110 -0
- package/distTs/src/main.js +190 -0
- package/distTs/src/output/pipeline.js +54 -56
- package/distTs/src/output.js +83 -26
- package/distTs/src/texts.js +450 -1
- package/distTs/src/tunnel/output/interactive/tunnel.js +28 -11
- package/distTs/src/tunnel/output/noninteractive/tunnel.js +17 -1
- package/distTs/src/tunnel/output/noninteractive/tunnelJsonl.js +8 -0
- package/distTs/src/types/options.js +2 -0
- package/distTs/src/types/scrape.js +2 -0
- package/distTs/src/types/tunnel.js +6 -1
- package/distTs/src/types/visualTests.js +2 -0
- package/distTs/src/utils.js +134 -3
- package/package.json +2 -1
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const cliError_1 = __importDefault(require("../../cliError"));
|
|
10
|
+
const shared_1 = require("./shared");
|
|
11
|
+
const commandPrDiff = (0, utils_1.newCommand)('diff', texts_1.DESC_COMMAND_PR_DIFF, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_READ],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_DIFF,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrDiff, true);
|
|
16
|
+
commandPrDiff.option('--full', texts_1.OPTION_PR_DIFF_FULL);
|
|
17
|
+
commandPrDiff.option('--from <version>', texts_1.OPTION_PR_DIFF_FROM);
|
|
18
|
+
// variadic so N can be left out: `[N] <path>` is split in the action
|
|
19
|
+
commandPrDiff.argument('<path...>', texts_1.OPTION_PR_DIFF_PATH);
|
|
20
|
+
commandPrDiff.usage('[options] [N] <path>');
|
|
21
|
+
/** A thread under its line: the same header as in pr get, then the whole conversation. */
|
|
22
|
+
const printThread = (thread, origin, indent = ' ') => {
|
|
23
|
+
const bar = output_1.default.getYellowColor(`${indent}┃`);
|
|
24
|
+
const extra = origin ? `, ${(0, texts_1.TXT_PR_MOVED_FROM)((0, shared_1.positionText)(origin))}` : '';
|
|
25
|
+
output_1.default.normal(`${bar} ${(0, shared_1.threadHeader)(thread, extra)}`);
|
|
26
|
+
const message = (who, date, text) => {
|
|
27
|
+
const lines = (text || '').split('\n');
|
|
28
|
+
output_1.default.normal(`${bar} ${output_1.default.getMutedColor(`${(0, shared_1.memberName)(who)} ${(0, shared_1.formatDate)(date)}:`)} ${lines[0]}`);
|
|
29
|
+
lines.slice(1).forEach((line) => output_1.default.normal(`${bar} ${line}`));
|
|
30
|
+
};
|
|
31
|
+
message(thread.author, thread.create_date, thread.comment);
|
|
32
|
+
for (const reply of thread.comments || [])
|
|
33
|
+
message(reply.user, reply.create_date, reply.comment);
|
|
34
|
+
const duplicates = thread.duplicates || [];
|
|
35
|
+
if (duplicates.length > 0) {
|
|
36
|
+
output_1.default.normal(`${bar} ${output_1.default.getMutedColor((0, texts_1.TXT_PR_SAME_CHANGE)(duplicates.map((d) => `${d.path}:${d.new_start}`).join(', ')))}`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const hunkHasThread = (hunk, threads) => hunk.lines.some((line) => threads.some((t) => (t.position?.new_line && t.position.new_line === line.newLine) ||
|
|
40
|
+
(t.position?.old_line && t.position.old_line === line.oldLine)));
|
|
41
|
+
/** Threads that were opened on this file and whose code is gone in the version. */
|
|
42
|
+
const goneThreads = async (scope, number, version, paths) => {
|
|
43
|
+
const all = await (0, shared_1.fetchAllThreads)(scope, number, { version });
|
|
44
|
+
const gone = (all.threads || []).filter((t) => t.position?.anchor_state === utils_1.PR_ANCHOR_STATE.GONE);
|
|
45
|
+
const result = [];
|
|
46
|
+
for (const thread of gone) {
|
|
47
|
+
const origin = await (0, shared_1.threadOrigin)(scope, number, thread);
|
|
48
|
+
if (origin?.path && paths.includes(origin.path)) {
|
|
49
|
+
result.push({ thread, origin });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
};
|
|
54
|
+
commandPrDiff.action(async (args, options) => {
|
|
55
|
+
const { number: n, rest } = (0, shared_1.splitNumberArgs)(args);
|
|
56
|
+
if (rest.length !== 1) {
|
|
57
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_DIFF_ARGS)(args.join(' ')));
|
|
58
|
+
}
|
|
59
|
+
const path = rest[0];
|
|
60
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
61
|
+
const fromVersion = (0, shared_1.parseRev)(options.from);
|
|
62
|
+
const json = options.format === 'json';
|
|
63
|
+
const scope = (0, shared_1.prScope)(options);
|
|
64
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
65
|
+
const { client, workspace, project } = scope;
|
|
66
|
+
const diff = await client.getPullRequestDiff(workspace, project, number, {
|
|
67
|
+
path,
|
|
68
|
+
version,
|
|
69
|
+
from_version: fromVersion,
|
|
70
|
+
full: options.full ? true : undefined,
|
|
71
|
+
});
|
|
72
|
+
const shown = diff.version;
|
|
73
|
+
// in a pipe (an agent) showing the file is reading it: mark it viewed in the version shown
|
|
74
|
+
const markViewed = !output_1.default.isStdOutTTY();
|
|
75
|
+
let viewedError = false;
|
|
76
|
+
if (markViewed) {
|
|
77
|
+
try {
|
|
78
|
+
await client.markPullRequestFilesViewed(workspace, project, number, {
|
|
79
|
+
paths: [diff.file_name || path],
|
|
80
|
+
viewed: true,
|
|
81
|
+
version: shown,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
viewedError = true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (json) {
|
|
89
|
+
output_1.default.json(diff);
|
|
90
|
+
output_1.default.exitNormal();
|
|
91
|
+
}
|
|
92
|
+
const [pr, info, threads, gone] = await Promise.all([
|
|
93
|
+
client.getPullRequest(workspace, project, number),
|
|
94
|
+
(0, shared_1.fetchAllFiles)(scope, number, { version: shown, path_prefix: diff.file_name || path }),
|
|
95
|
+
(0, shared_1.fetchAllThreads)(scope, number, { version: shown, path: diff.file_name || path }),
|
|
96
|
+
goneThreads(scope, number, shown, [diff.file_name || path, diff.previous_file_name].filter(Boolean)),
|
|
97
|
+
]);
|
|
98
|
+
(0, shared_1.noteVersionBehind)(pr?.version, shown);
|
|
99
|
+
const file = (info.files || []).find((f) => f.file_name === (diff.file_name || path));
|
|
100
|
+
const threadList = threads.threads || [];
|
|
101
|
+
const origins = new Map();
|
|
102
|
+
for (const thread of threadList) {
|
|
103
|
+
const origin = await (0, shared_1.threadOrigin)(scope, number, thread);
|
|
104
|
+
if (origin)
|
|
105
|
+
origins.set(thread.id, origin);
|
|
106
|
+
}
|
|
107
|
+
// header: the file with its status and priority, then one fact per line
|
|
108
|
+
const title = [
|
|
109
|
+
output_1.default.getLabelColor(diff.previous_file_name ? `${diff.file_name} ← ${diff.previous_file_name}` : diff.file_name),
|
|
110
|
+
(0, shared_1.fileStatusText)(diff.status),
|
|
111
|
+
(0, shared_1.filePriorityText)(file?.triage?.review_priority),
|
|
112
|
+
].filter(Boolean);
|
|
113
|
+
output_1.default.normal(title.join(' '));
|
|
114
|
+
const versionText = `v${shown}${pr?.version === shown ? ` ${texts_1.TXT_PR_DIFF_CURRENT}` : ''}`;
|
|
115
|
+
// a full diff without --full collapses cosmetic and repeated hunks (not those with a thread)
|
|
116
|
+
const hunks = (0, shared_1.parsePatch)(diff.patch);
|
|
117
|
+
const collapse = diff.mode === utils_1.PR_DIFF_MODE.FULL && !options.full;
|
|
118
|
+
const collapsedKind = (hunk, index) => {
|
|
119
|
+
const meta = diff.hunks?.[index];
|
|
120
|
+
if (!collapse || !meta || hunkHasThread(hunk, threadList))
|
|
121
|
+
return null;
|
|
122
|
+
if (meta.type === utils_1.PR_HUNK_TYPE.COSMETIC)
|
|
123
|
+
return 'cosmetic';
|
|
124
|
+
if (meta.duplicate_of)
|
|
125
|
+
return 'duplicate';
|
|
126
|
+
return null;
|
|
127
|
+
};
|
|
128
|
+
const collapsedCount = hunks.filter((hunk, index) => collapsedKind(hunk, index)).length;
|
|
129
|
+
const mode = diff.mode === utils_1.PR_DIFF_MODE.INTERDIFF
|
|
130
|
+
? (0, texts_1.TXT_PR_DIFF_MODE_INTERDIFF)(diff.from_version, fromVersion === undefined)
|
|
131
|
+
: options.full
|
|
132
|
+
? (0, texts_1.TXT_PR_DIFF_MODE_FULL)(pr?.base)
|
|
133
|
+
: (0, texts_1.TXT_PR_DIFF_MODE_DEFAULT)(pr?.base, collapsedCount);
|
|
134
|
+
output_1.default.normal(` ${(0, shared_1.field)(texts_1.TXT_PR_DIFF_FIELD_VERSION, versionText)} · ${mode}`);
|
|
135
|
+
if (file?.analysis) {
|
|
136
|
+
output_1.default.normal(` ${output_1.default.getMutedColor(texts_1.TXT_PR_DIFF_FIELD_TYPE)} ${(0, shared_1.changeTypeText)(file.analysis.change_type)} · ${output_1.default.getLabelColor(`${(0, shared_1.fileSizeText)(file)} tokens`)}`);
|
|
137
|
+
}
|
|
138
|
+
const symbols = file?.analysis?.changed_symbols || [];
|
|
139
|
+
if (symbols.length > 0) {
|
|
140
|
+
output_1.default.normal(` ${output_1.default.getMutedColor(texts_1.TXT_PR_DIFF_FIELD_SYMBOLS)}`);
|
|
141
|
+
(0, shared_1.symbolLines)(symbols).forEach((line) => output_1.default.normal(` ${line}`));
|
|
142
|
+
}
|
|
143
|
+
output_1.default.newline();
|
|
144
|
+
if (diff.binary)
|
|
145
|
+
output_1.default.muted(texts_1.TXT_PR_DIFF_BINARY);
|
|
146
|
+
if (diff.truncated)
|
|
147
|
+
output_1.default.warning(texts_1.TXT_PR_DIFF_TRUNCATED);
|
|
148
|
+
if (!diff.binary && !diff.truncated && hunks.length === 0) {
|
|
149
|
+
output_1.default.muted(texts_1.TXT_PR_DIFF_EMPTY);
|
|
150
|
+
}
|
|
151
|
+
const width = (0, shared_1.patchColumnWidth)(hunks);
|
|
152
|
+
// where the +/- sign and the code start, for collapsed hunks and threads
|
|
153
|
+
const indent = ' '.repeat(width * 2 + 2);
|
|
154
|
+
const placed = new Set();
|
|
155
|
+
hunks.forEach((hunk, index) => {
|
|
156
|
+
const meta = diff.hunks?.[index];
|
|
157
|
+
output_1.default.normal((0, shared_1.hunkHeaderText)(hunk.header, width));
|
|
158
|
+
const kind = collapsedKind(hunk, index);
|
|
159
|
+
if (kind === 'cosmetic') {
|
|
160
|
+
output_1.default.muted(`${indent}${(0, texts_1.TXT_PR_DIFF_COSMETIC)(hunk.lines.length)}`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (kind === 'duplicate') {
|
|
164
|
+
output_1.default.muted(`${indent}${(0, texts_1.TXT_PR_DIFF_DUPLICATE)(`${meta.duplicate_of.path}:${meta.duplicate_of.new_start}`, meta.duplicate_count)}`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
for (const line of hunk.lines) {
|
|
168
|
+
output_1.default.normal(line.type === 'meta' ? line.text : (0, shared_1.formatPatchLine)(line, width));
|
|
169
|
+
for (const thread of threadList) {
|
|
170
|
+
if (placed.has(thread.id))
|
|
171
|
+
continue;
|
|
172
|
+
const p = thread.position || {};
|
|
173
|
+
const onNew = p.new_line && line.newLine === p.new_line && line.type !== 'del';
|
|
174
|
+
const onOld = p.old_line && line.oldLine === p.old_line && line.type !== 'add';
|
|
175
|
+
if (onNew || onOld) {
|
|
176
|
+
printThread(thread, origins.get(thread.id), indent);
|
|
177
|
+
placed.add(thread.id);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
const removed = diff.removed_hunks || [];
|
|
183
|
+
if (removed.length > 0) {
|
|
184
|
+
output_1.default.newline();
|
|
185
|
+
output_1.default.label((0, texts_1.TXT_PR_DIFF_REMOVED)(diff.from_version, shown));
|
|
186
|
+
for (const hunk of removed) {
|
|
187
|
+
// the text of a removed hunk, with its header when the API sends none
|
|
188
|
+
const text = hunk.patch || '';
|
|
189
|
+
const patch = text.startsWith('@@')
|
|
190
|
+
? text
|
|
191
|
+
: `@@ -${hunk.old_start} +${hunk.new_start} @@\n${text}`;
|
|
192
|
+
for (const parsed of (0, shared_1.parsePatch)(patch)) {
|
|
193
|
+
output_1.default.normal((0, shared_1.hunkHeaderText)(parsed.header, width));
|
|
194
|
+
parsed.lines.forEach((line) => output_1.default.normal((0, shared_1.formatPatchLine)(line, width)));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const unplaced = threadList.filter((t) => !placed.has(t.id));
|
|
199
|
+
if (unplaced.length > 0) {
|
|
200
|
+
output_1.default.newline();
|
|
201
|
+
output_1.default.label(texts_1.TXT_PR_SECTION_THREADS);
|
|
202
|
+
unplaced.forEach((t) => {
|
|
203
|
+
output_1.default.muted(` ${(0, shared_1.positionText)(t.position)}`);
|
|
204
|
+
printThread(t, origins.get(t.id));
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
if (gone.length > 0) {
|
|
208
|
+
output_1.default.newline();
|
|
209
|
+
output_1.default.label(texts_1.TXT_PR_DIFF_GONE);
|
|
210
|
+
gone.forEach(({ thread, origin }) => {
|
|
211
|
+
output_1.default.muted(` ${(0, texts_1.TXT_PR_OPENED_AT)((0, shared_1.positionText)(origin), thread.created_version)}`);
|
|
212
|
+
printThread(thread, null);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
output_1.default.newline();
|
|
216
|
+
if (markViewed) {
|
|
217
|
+
if (viewedError)
|
|
218
|
+
output_1.default.noteWarning(texts_1.TXT_PR_DIFF_VIEW_FAILED);
|
|
219
|
+
else
|
|
220
|
+
output_1.default.muted((0, texts_1.TXT_PR_DIFF_VIEWED)(shown));
|
|
221
|
+
}
|
|
222
|
+
else if (!file?.viewed) {
|
|
223
|
+
output_1.default.muted((0, texts_1.TXT_PR_DIFF_VIEW_HINT)(scope.cmd(`file viewed ${number} ${diff.file_name || path} --rev v${shown}`)));
|
|
224
|
+
}
|
|
225
|
+
output_1.default.exitNormal();
|
|
226
|
+
});
|
|
227
|
+
exports.default = commandPrDiff;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
10
|
+
const shared_1 = require("../shared");
|
|
11
|
+
const summary_1 = require("../summary");
|
|
12
|
+
const commandPrFileList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PR_FILE_LIST, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_READ],
|
|
14
|
+
examples: texts_1.EXAMPLE_PR_FILE_LIST,
|
|
15
|
+
});
|
|
16
|
+
commandPrFileList.alias('ls');
|
|
17
|
+
(0, shared_1.addPrOptions)(commandPrFileList, true);
|
|
18
|
+
commandPrFileList.option('--since-review', texts_1.OPTION_PR_FILES_SINCE_REVIEW);
|
|
19
|
+
commandPrFileList.option('--must-review', texts_1.OPTION_PR_FILES_MUST_REVIEW);
|
|
20
|
+
commandPrFileList.option('--unclear', texts_1.OPTION_PR_FILES_UNCLEAR);
|
|
21
|
+
commandPrFileList.option('--batch <k>', texts_1.OPTION_PR_FILES_BATCH);
|
|
22
|
+
commandPrFileList.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
23
|
+
commandPrFileList.action(async (n, options) => {
|
|
24
|
+
const filters = [
|
|
25
|
+
options.sinceReview,
|
|
26
|
+
options.mustReview,
|
|
27
|
+
options.unclear,
|
|
28
|
+
options.batch !== undefined,
|
|
29
|
+
].filter(Boolean);
|
|
30
|
+
if (filters.length > 1)
|
|
31
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_FILE_FILTERS);
|
|
32
|
+
let batch;
|
|
33
|
+
if (options.batch !== undefined) {
|
|
34
|
+
if (!/^[1-9]\d*$/.test(options.batch))
|
|
35
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_BATCH);
|
|
36
|
+
batch = Number(options.batch);
|
|
37
|
+
}
|
|
38
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
39
|
+
const scope = (0, shared_1.prScope)(options);
|
|
40
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
41
|
+
let result;
|
|
42
|
+
let files;
|
|
43
|
+
if (options.mustReview || batch !== undefined) {
|
|
44
|
+
result = await (0, shared_1.fetchMustReview)(scope, number, version);
|
|
45
|
+
files = result.files || [];
|
|
46
|
+
if (batch !== undefined) {
|
|
47
|
+
const batches = (0, shared_1.buildBatches)(files);
|
|
48
|
+
if (batches.length === 0) {
|
|
49
|
+
const tokens = files.reduce((sum, f) => sum + (0, shared_1.tokensOf)(f), 0);
|
|
50
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_NO_BATCHES)(files.length, tokens));
|
|
51
|
+
}
|
|
52
|
+
if (batch > batches.length) {
|
|
53
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_BATCH_RANGE)(batch, batches.length));
|
|
54
|
+
}
|
|
55
|
+
files = batches[batch - 1].files;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else if (options.unclear) {
|
|
59
|
+
result = await (0, shared_1.fetchAllFiles)(scope, number, {
|
|
60
|
+
version,
|
|
61
|
+
review_priority: utils_1.PR_REVIEW_PRIORITY.UNCLEAR,
|
|
62
|
+
sort: utils_1.PR_FILES_SORT.REVIEW_ORDER,
|
|
63
|
+
});
|
|
64
|
+
files = result.files || [];
|
|
65
|
+
}
|
|
66
|
+
else if (options.sinceReview) {
|
|
67
|
+
result = await (0, shared_1.fetchAllFiles)(scope, number, { version, since_review: true });
|
|
68
|
+
files = result.files || [];
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
result = await (0, shared_1.fetchAllFiles)(scope, number, { version });
|
|
72
|
+
files = result.files || [];
|
|
73
|
+
}
|
|
74
|
+
if (options.format === 'json') {
|
|
75
|
+
output_1.default.json(files);
|
|
76
|
+
output_1.default.exitNormal();
|
|
77
|
+
}
|
|
78
|
+
if (version) {
|
|
79
|
+
const pr = await scope.client.getPullRequest(scope.workspace, scope.project, number);
|
|
80
|
+
(0, shared_1.noteVersionBehind)(pr?.version, result.version);
|
|
81
|
+
}
|
|
82
|
+
if (files.length === 0)
|
|
83
|
+
output_1.default.exitNormal(texts_1.TXT_PR_FILES_NOT_FOUND);
|
|
84
|
+
// the reason a file is on the since-review list needs the threads not CLOSED
|
|
85
|
+
let byPath = new Map();
|
|
86
|
+
if (options.sinceReview) {
|
|
87
|
+
const threads = await (0, shared_1.fetchAllThreads)(scope, number, { version: result.version });
|
|
88
|
+
byPath = (0, summary_1.threadsByPath)(threads.threads || []);
|
|
89
|
+
}
|
|
90
|
+
const data = [
|
|
91
|
+
['STATUS', '+/-', 'VIEWED', 'CHANGED', 'PRIORITY', 'TYPE', 'SIZE/TOKENS', 'PATH', 'SYMBOLS'],
|
|
92
|
+
];
|
|
93
|
+
const sorted = (0, shared_1.sortFilesForReading)(files);
|
|
94
|
+
for (const file of sorted) {
|
|
95
|
+
const symbols = file.analysis?.changed_symbols || [];
|
|
96
|
+
const flags = [];
|
|
97
|
+
if (file.analysis?.has_only_duplicated_hunks)
|
|
98
|
+
flags.push('only repeated changes');
|
|
99
|
+
if (options.sinceReview) {
|
|
100
|
+
const reason = (0, summary_1.sinceReviewReason)(file, byPath);
|
|
101
|
+
if (reason)
|
|
102
|
+
flags.push(reason);
|
|
103
|
+
}
|
|
104
|
+
const path = file.previous_file_name
|
|
105
|
+
? `${file.file_name} ← ${file.previous_file_name}`
|
|
106
|
+
: file.file_name;
|
|
107
|
+
data.push([
|
|
108
|
+
(0, shared_1.fileStatusText)(file.status),
|
|
109
|
+
`+${file.additions ?? 0}/-${file.deletions ?? 0}`,
|
|
110
|
+
file.viewed ? output_1.default.getGreenColor('yes') : 'no',
|
|
111
|
+
file.changed_since_review === null || file.changed_since_review === undefined
|
|
112
|
+
? '-'
|
|
113
|
+
: file.changed_since_review ? 'yes' : 'no',
|
|
114
|
+
(0, shared_1.filePriorityText)(file.triage?.review_priority) || '-',
|
|
115
|
+
(0, shared_1.changeTypeText)(file.analysis?.change_type),
|
|
116
|
+
(0, shared_1.fileSizeText)(file),
|
|
117
|
+
flags.length ? `${path} (${flags.join(', ')})` : path,
|
|
118
|
+
symbols.slice(0, 3).map((s) => s.name).join(', ') + (symbols.length > 3 ? ` +${symbols.length - 3}` : ''),
|
|
119
|
+
]);
|
|
120
|
+
}
|
|
121
|
+
output_1.default.table(data, true, true);
|
|
122
|
+
output_1.default.exitNormal();
|
|
123
|
+
});
|
|
124
|
+
exports.default = commandPrFileList;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.commandPrFileUnviewed = exports.commandPrFileViewed = void 0;
|
|
7
|
+
const utils_1 = require("../../../utils");
|
|
8
|
+
const texts_1 = require("../../../texts");
|
|
9
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
11
|
+
const shared_1 = require("../shared");
|
|
12
|
+
// the API takes up to 500 paths per request
|
|
13
|
+
const CHUNK = 500;
|
|
14
|
+
const markCommand = (viewed) => {
|
|
15
|
+
const command = (0, utils_1.newCommand)(viewed ? 'viewed' : 'unviewed', viewed ? texts_1.DESC_COMMAND_PR_FILE_VIEWED : texts_1.DESC_COMMAND_PR_FILE_UNVIEWED, {
|
|
16
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
17
|
+
examples: viewed ? texts_1.EXAMPLE_PR_FILE_VIEWED : texts_1.EXAMPLE_PR_FILE_UNVIEWED,
|
|
18
|
+
});
|
|
19
|
+
(0, shared_1.addPrOptions)(command, true);
|
|
20
|
+
// `[N] <path...>`: N is split off in the action
|
|
21
|
+
command.argument('<paths...>', texts_1.OPTION_PR_FILE_PATHS);
|
|
22
|
+
command.usage('[options] [N] <path...>');
|
|
23
|
+
command.action(async (args, options) => {
|
|
24
|
+
const { number: n, rest: paths } = (0, shared_1.splitNumberArgs)(args);
|
|
25
|
+
if (paths.length === 0) {
|
|
26
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_ARGS)('[N] <path...>', args.join(' ')));
|
|
27
|
+
}
|
|
28
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
29
|
+
const scope = (0, shared_1.prScope)(options);
|
|
30
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
31
|
+
const files = [];
|
|
32
|
+
let shown = version;
|
|
33
|
+
for (let i = 0; i < paths.length; i += CHUNK) {
|
|
34
|
+
const result = await scope.client.markPullRequestFilesViewed(scope.workspace, scope.project, number, { paths: paths.slice(i, i + CHUNK), viewed, version });
|
|
35
|
+
shown = result?.version ?? shown;
|
|
36
|
+
files.push(...(result?.files || []));
|
|
37
|
+
}
|
|
38
|
+
output_1.default.exitResult(options.format === 'json', { version: shown, files }, viewed
|
|
39
|
+
? (0, texts_1.TXT_PR_FILES_VIEWED)(paths.length, shown)
|
|
40
|
+
: (0, texts_1.TXT_PR_FILES_UNVIEWED)(paths.length, shown));
|
|
41
|
+
});
|
|
42
|
+
return command;
|
|
43
|
+
};
|
|
44
|
+
exports.commandPrFileViewed = markCommand(true);
|
|
45
|
+
exports.commandPrFileUnviewed = markCommand(false);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const list_1 = __importDefault(require("./file/list"));
|
|
9
|
+
const mark_1 = require("./file/mark");
|
|
10
|
+
const commandPrFile = (0, utils_1.newCommand)('file', texts_1.DESC_COMMAND_PR_FILE, {
|
|
11
|
+
examples: texts_1.EXAMPLE_PR_FILE,
|
|
12
|
+
});
|
|
13
|
+
commandPrFile.addCommand(list_1.default);
|
|
14
|
+
commandPrFile.addCommand(mark_1.commandPrFileViewed);
|
|
15
|
+
commandPrFile.addCommand(mark_1.commandPrFileUnviewed);
|
|
16
|
+
exports.default = commandPrFile;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const shared_1 = require("./shared");
|
|
10
|
+
const summary_1 = require("./summary");
|
|
11
|
+
const commandPrGet = (0, utils_1.newCommand)('get', texts_1.DESC_COMMAND_PR_GET, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_READ],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_GET,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrGet, true);
|
|
16
|
+
commandPrGet.option('--since-review', texts_1.OPTION_PR_SINCE_REVIEW_GET);
|
|
17
|
+
commandPrGet.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
18
|
+
commandPrGet.action(async (n, options) => {
|
|
19
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
20
|
+
const scope = (0, shared_1.prScope)(options);
|
|
21
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
22
|
+
await (0, summary_1.printSummary)(scope, number, {
|
|
23
|
+
rev: version,
|
|
24
|
+
sinceReview: !!options.sinceReview,
|
|
25
|
+
json: options.format === 'json',
|
|
26
|
+
});
|
|
27
|
+
output_1.default.exitNormal();
|
|
28
|
+
});
|
|
29
|
+
exports.default = commandPrGet;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const input_1 = __importDefault(require("../../input"));
|
|
10
|
+
const cliError_1 = __importDefault(require("../../cliError"));
|
|
11
|
+
const shared_1 = require("./shared");
|
|
12
|
+
const commandPrList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PR_LIST, {
|
|
13
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_READ],
|
|
14
|
+
examples: texts_1.EXAMPLE_PR_LIST,
|
|
15
|
+
});
|
|
16
|
+
commandPrList.alias('ls');
|
|
17
|
+
(0, shared_1.addPrOptions)(commandPrList);
|
|
18
|
+
commandPrList.option('--state <state>', texts_1.OPTION_PR_STATE);
|
|
19
|
+
commandPrList.option('--author <login|me>', texts_1.OPTION_PR_AUTHOR);
|
|
20
|
+
commandPrList.option('--reviewer <login|me>', texts_1.OPTION_PR_REVIEWER);
|
|
21
|
+
commandPrList.option('--head <branch>', texts_1.OPTION_PR_HEAD_FILTER);
|
|
22
|
+
commandPrList.option('--base <branch>', texts_1.OPTION_PR_BASE_FILTER);
|
|
23
|
+
commandPrList.option('--page <number>', texts_1.OPTION_REST_API_PAGE);
|
|
24
|
+
commandPrList.option('--per-page <number>', texts_1.OPTION_PR_PER_PAGE);
|
|
25
|
+
// `me` is the invoker; the API takes a username or an e-mail
|
|
26
|
+
const login = async (scope, value) => {
|
|
27
|
+
if (value !== 'me')
|
|
28
|
+
return value;
|
|
29
|
+
const user = await scope.client.getInvoker();
|
|
30
|
+
return user?.email;
|
|
31
|
+
};
|
|
32
|
+
commandPrList.action(async (options) => {
|
|
33
|
+
let state;
|
|
34
|
+
if (options.state) {
|
|
35
|
+
state = String(options.state).toUpperCase();
|
|
36
|
+
if (!Object.values(utils_1.PR_STATE).includes(state)) {
|
|
37
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_STATE);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const page = options.page ? input_1.default.restApiPage(options.page) : undefined;
|
|
41
|
+
const perPage = options.perPage
|
|
42
|
+
? input_1.default.restApiPerPage(options.perPage)
|
|
43
|
+
: undefined;
|
|
44
|
+
const scope = (0, shared_1.prScope)(options);
|
|
45
|
+
const result = await scope.client.getPullRequests(scope.workspace, scope.project, {
|
|
46
|
+
state,
|
|
47
|
+
author: await login(scope, options.author),
|
|
48
|
+
reviewer: await login(scope, options.reviewer),
|
|
49
|
+
head: options.head,
|
|
50
|
+
base: options.base,
|
|
51
|
+
page,
|
|
52
|
+
per_page: perPage,
|
|
53
|
+
});
|
|
54
|
+
const prs = result?.pull_requests || [];
|
|
55
|
+
if (options.format === 'json') {
|
|
56
|
+
output_1.default.json(prs);
|
|
57
|
+
output_1.default.exitNormal();
|
|
58
|
+
}
|
|
59
|
+
if (prs.length === 0)
|
|
60
|
+
output_1.default.exitNormal(texts_1.TXT_PR_NOT_FOUND);
|
|
61
|
+
const data = [
|
|
62
|
+
['#', 'TITLE', 'STATE', 'MERGEABLE', 'BRANCHES', 'AUTHOR', 'VERSION', 'UPDATED'],
|
|
63
|
+
];
|
|
64
|
+
for (const pr of prs) {
|
|
65
|
+
data.push([
|
|
66
|
+
String(pr.number ?? '-'),
|
|
67
|
+
pr.title || '-',
|
|
68
|
+
(0, shared_1.prStateText)(pr),
|
|
69
|
+
(0, shared_1.mergeableText)(pr.mergeable),
|
|
70
|
+
pr.head ? `${pr.base} ← ${pr.head}` : '-',
|
|
71
|
+
pr.author ? (0, shared_1.memberName)(pr.author) : '-',
|
|
72
|
+
pr.version ? `v${pr.version}` : '-',
|
|
73
|
+
(0, shared_1.formatDate)(pr.last_update_date || pr.create_date),
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
output_1.default.table(data, true, true);
|
|
77
|
+
output_1.default.exitNormal();
|
|
78
|
+
});
|
|
79
|
+
exports.default = commandPrList;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const texts_1 = require("../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../output"));
|
|
9
|
+
const cliError_1 = __importDefault(require("../../cliError"));
|
|
10
|
+
const shared_1 = require("./shared");
|
|
11
|
+
const commandPrMerge = (0, utils_1.newCommand)('merge', texts_1.DESC_COMMAND_PR_MERGE, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_MERGE,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrMerge, true);
|
|
16
|
+
commandPrMerge.option('--method <method>', texts_1.OPTION_PR_MERGE_METHOD);
|
|
17
|
+
commandPrMerge.option('--delete-branch', texts_1.OPTION_PR_DELETE_BRANCH);
|
|
18
|
+
commandPrMerge.option('--message <text|@path|->', texts_1.OPTION_PR_MERGE_MESSAGE);
|
|
19
|
+
commandPrMerge.option('--no-review', texts_1.OPTION_PR_NO_REVIEW);
|
|
20
|
+
commandPrMerge.option('-f, --force', texts_1.OPTION_CONFIRM_FORCE);
|
|
21
|
+
commandPrMerge.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
22
|
+
commandPrMerge.action(async (n, options) => {
|
|
23
|
+
const method = String(options.method || utils_1.PR_MERGE_METHOD.MERGE).toUpperCase();
|
|
24
|
+
if (!Object.values(utils_1.PR_MERGE_METHOD).includes(method)) {
|
|
25
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_MERGE_METHOD);
|
|
26
|
+
}
|
|
27
|
+
const rev = (0, shared_1.parseRev)(options.rev);
|
|
28
|
+
const commitMessage = (0, shared_1.readText)(options.message, false);
|
|
29
|
+
const json = options.format === 'json';
|
|
30
|
+
const scope = (0, shared_1.prScope)(options);
|
|
31
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
32
|
+
const { client, workspace, project } = scope;
|
|
33
|
+
// the version is fixed before the prompt, so a version that appears meanwhile is refused (409)
|
|
34
|
+
const pr = await client.getPullRequest(workspace, project, number);
|
|
35
|
+
const version = rev ?? pr.version;
|
|
36
|
+
if (!json)
|
|
37
|
+
(0, shared_1.noteVersionBehind)(pr.version, version);
|
|
38
|
+
// -f skips only the prompt; --no-review skips this check
|
|
39
|
+
if (options.review !== false) {
|
|
40
|
+
const result = await client.getPullRequestReviews(workspace, project, number);
|
|
41
|
+
const reviews = result?.reviews || [];
|
|
42
|
+
if (!reviews.some((r) => r.verdict === utils_1.PR_VERDICT.APPROVED)) {
|
|
43
|
+
throw new cliError_1.default('usage_error', texts_1.ERR_PR_NOT_APPROVED);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const confirmed = await output_1.default.confirmDestructive(options.force, (0, texts_1.TXT_PR_MERGE_CONFIRM)(number, version, method), json);
|
|
47
|
+
if (!confirmed)
|
|
48
|
+
output_1.default.exitResult(json, { merged: null });
|
|
49
|
+
let merged;
|
|
50
|
+
try {
|
|
51
|
+
merged = await client.mergePullRequest(workspace, project, number, {
|
|
52
|
+
version,
|
|
53
|
+
method,
|
|
54
|
+
delete_branch: options.deleteBranch ? true : undefined,
|
|
55
|
+
commit_message: commitMessage,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
if ((0, shared_1.isVersionConflict)(err)) {
|
|
60
|
+
throw new cliError_1.default('usage_error', (0, texts_1.TXT_PR_MERGE_VERSION_CONFLICT)(scope.cmd, number, (0, shared_1.conflictVersion)(err)));
|
|
61
|
+
}
|
|
62
|
+
throw err;
|
|
63
|
+
}
|
|
64
|
+
output_1.default.exitResult(json, merged, (0, texts_1.TXT_PR_MERGED)(number, version));
|
|
65
|
+
});
|
|
66
|
+
exports.default = commandPrMerge;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const cliError_1 = __importDefault(require("../../../cliError"));
|
|
10
|
+
const shared_1 = require("../shared");
|
|
11
|
+
const commandPrReviewRequest = (0, utils_1.newCommand)('request', texts_1.DESC_COMMAND_PR_REVIEW_REQUEST, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_REVIEW_REQUEST,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrReviewRequest);
|
|
16
|
+
// `[N] <login...>`: N is split off in the action
|
|
17
|
+
commandPrReviewRequest.argument('<logins...>', texts_1.OPTION_PR_REVIEW_LOGINS);
|
|
18
|
+
commandPrReviewRequest.usage('[options] [N] <login...>');
|
|
19
|
+
commandPrReviewRequest.action(async (args, options) => {
|
|
20
|
+
const { number: n, rest: logins } = (0, shared_1.splitNumberArgs)(args);
|
|
21
|
+
if (logins.length === 0) {
|
|
22
|
+
throw new cliError_1.default('usage_error', (0, texts_1.ERR_PR_ARGS)('[N] <login...>', args.join(' ')));
|
|
23
|
+
}
|
|
24
|
+
const scope = (0, shared_1.prScope)(options);
|
|
25
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
26
|
+
const pr = await scope.client.requestPullRequestReview(scope.workspace, scope.project, number, logins);
|
|
27
|
+
output_1.default.exitResult(options.format === 'json', pr, (0, texts_1.TXT_PR_REVIEW_REQUESTED)(logins.join(', ')));
|
|
28
|
+
});
|
|
29
|
+
exports.default = commandPrReviewRequest;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const texts_1 = require("../../../texts");
|
|
8
|
+
const output_1 = __importDefault(require("../../../output"));
|
|
9
|
+
const shared_1 = require("../shared");
|
|
10
|
+
const summary_1 = require("../summary");
|
|
11
|
+
const commandPrReviewStart = (0, utils_1.newCommand)('start', texts_1.DESC_COMMAND_PR_REVIEW_START, {
|
|
12
|
+
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
13
|
+
examples: texts_1.EXAMPLE_PR_REVIEW_START,
|
|
14
|
+
});
|
|
15
|
+
(0, shared_1.addPrOptions)(commandPrReviewStart, true);
|
|
16
|
+
commandPrReviewStart.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
17
|
+
commandPrReviewStart.action(async (n, options) => {
|
|
18
|
+
const version = (0, shared_1.parseRev)(options.rev);
|
|
19
|
+
const scope = (0, shared_1.prScope)(options);
|
|
20
|
+
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
21
|
+
// idempotent: an existing review stays as it is
|
|
22
|
+
await scope.client.startPullRequestReview(scope.workspace, scope.project, number, version);
|
|
23
|
+
await (0, summary_1.printSummary)(scope, number, {
|
|
24
|
+
rev: version,
|
|
25
|
+
json: options.format === 'json',
|
|
26
|
+
});
|
|
27
|
+
output_1.default.exitNormal();
|
|
28
|
+
});
|
|
29
|
+
exports.default = commandPrReviewStart;
|