bdy 1.25.38-dev-pr → 1.25.38-stage
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 +1 -2
- package/distTs/src/api/client.js +1 -191
- package/distTs/src/cliError.js +0 -5
- package/distTs/src/cliIndex.js +0 -3
- package/distTs/src/command/login.js +1 -1
- package/distTs/src/output/pipeline.js +56 -54
- package/distTs/src/output.js +22 -72
- package/distTs/src/texts.js +1 -450
- package/distTs/src/tunnel/output/interactive/tunnel.js +10 -14
- package/distTs/src/tunnel/output/noninteractive/tunnel.js +1 -3
- package/distTs/src/utils.js +3 -133
- package/package.json +1 -2
- package/distTs/src/autocomplete.js +0 -90
- package/distTs/src/command/artifact/downloadDir.js +0 -110
- package/distTs/src/command/autocomplete/install.js +0 -16
- package/distTs/src/command/autocomplete/uninstall.js +0 -16
- package/distTs/src/command/autocomplete.js +0 -14
- package/distTs/src/command/environment/resolve.js +0 -39
- package/distTs/src/command/package/create.js +0 -64
- package/distTs/src/command/package/delete.js +0 -38
- package/distTs/src/command/package/docker/login.js +0 -26
- package/distTs/src/command/package/docker.js +0 -11
- package/distTs/src/command/package/download.js +0 -138
- package/distTs/src/command/package/get.js +0 -36
- package/distTs/src/command/package/list.js +0 -31
- package/distTs/src/command/package/publish.js +0 -241
- package/distTs/src/command/package/version/delete.js +0 -39
- package/distTs/src/command/package/version/get.js +0 -45
- package/distTs/src/command/package/version/list.js +0 -47
- package/distTs/src/command/package/version.js +0 -16
- package/distTs/src/command/package.js +0 -26
- package/distTs/src/command/pipeline/run/apply.js +0 -62
- package/distTs/src/command/pr/comment/add.js +0 -66
- package/distTs/src/command/pr/comment/list.js +0 -169
- package/distTs/src/command/pr/comment/status.js +0 -48
- package/distTs/src/command/pr/comment.js +0 -19
- package/distTs/src/command/pr/create.js +0 -43
- package/distTs/src/command/pr/diff.js +0 -227
- package/distTs/src/command/pr/file/list.js +0 -124
- package/distTs/src/command/pr/file/mark.js +0 -45
- package/distTs/src/command/pr/file.js +0 -16
- package/distTs/src/command/pr/get.js +0 -29
- package/distTs/src/command/pr/list.js +0 -79
- package/distTs/src/command/pr/merge.js +0 -66
- package/distTs/src/command/pr/review/request.js +0 -29
- package/distTs/src/command/pr/review/start.js +0 -29
- package/distTs/src/command/pr/review/verdict.js +0 -81
- package/distTs/src/command/pr/review.js +0 -18
- package/distTs/src/command/pr/shared.js +0 -595
- package/distTs/src/command/pr/state.js +0 -38
- package/distTs/src/command/pr/summary.js +0 -316
- package/distTs/src/command/pr/update.js +0 -54
- package/distTs/src/command/pr/updateBranch.js +0 -22
- package/distTs/src/command/pr/versions.js +0 -42
- package/distTs/src/command/pr.js +0 -39
- package/distTs/src/command/scrape/validation.js +0 -154
- package/distTs/src/command/scrape.js +0 -144
- package/distTs/src/command/suiteLink.js +0 -14
- package/distTs/src/command/tests/visual/result/download.js +0 -31
- package/distTs/src/command/tests/visual/result/get.js +0 -68
- package/distTs/src/command/tests/visual/result/list.js +0 -49
- package/distTs/src/command/tests/visual/result.js +0 -23
- package/distTs/src/command/tests/visual/session/get.js +0 -70
- package/distTs/src/command/tests/visual/session/list.js +0 -69
- package/distTs/src/command/tests/visual/session/open.js +0 -22
- package/distTs/src/command/tests/visual/session/reviewUrl.js +0 -37
- package/distTs/src/command/tests/visual/session/update.js +0 -26
- package/distTs/src/command/tests/visual/shared/context.js +0 -144
- package/distTs/src/command/tests/visual/shared/diffRegions.js +0 -172
- package/distTs/src/command/tests/visual/shared/format.js +0 -21
- package/distTs/src/command/tests/visual/shared/lookup.js +0 -107
- package/distTs/src/command/tests/visual/shared/options.js +0 -90
- package/distTs/src/command/tests/visual/shared/review.js +0 -146
- package/distTs/src/command/tests/visual/shared/reviewUrl.js +0 -62
- package/distTs/src/command/tests/visual/shared/session.js +0 -217
- package/distTs/src/command/tests/visual/snapshot/get.js +0 -46
- package/distTs/src/command/tests/visual/snapshot/list.js +0 -68
- package/distTs/src/command/tests/visual/snapshot/open.js +0 -26
- package/distTs/src/command/tests/visual/snapshot/reviewUrl.js +0 -48
- package/distTs/src/command/tests/visual/snapshot.js +0 -28
- package/distTs/src/command/tests/visual/suite/create.js +0 -38
- package/distTs/src/command/tests/visual/suite/delete.js +0 -29
- package/distTs/src/command/tests/visual/suite/get.js +0 -43
- package/distTs/src/command/tests/visual/suite/list.js +0 -35
- package/distTs/src/command/tests/visual/suite/open.js +0 -20
- package/distTs/src/command/tests/visual/suite/update.js +0 -47
- package/distTs/src/command/tests/visual/suite.js +0 -30
- package/distTs/src/command/ut/upload.js +0 -86
- package/distTs/src/command/ut.js +0 -12
- package/distTs/src/command/vt/close.js +0 -27
- package/distTs/src/command/vt/compare/validation.js +0 -46
- package/distTs/src/command/vt/compare.js +0 -100
- package/distTs/src/command/vt/exec.js +0 -82
- package/distTs/src/command/vt/installBrowser.js +0 -20
- package/distTs/src/command/vt/shared/validation.js +0 -145
- package/distTs/src/command/vt/storybook.js +0 -138
- package/distTs/src/command/vt.js +0 -20
- package/distTs/src/command/yaml/agents.js +0 -88
- package/distTs/src/command/yaml/init.js +0 -110
- package/distTs/src/main.js +0 -190
- package/distTs/src/types/options.js +0 -2
- package/distTs/src/types/scrape.js +0 -2
- package/distTs/src/types/visualTests.js +0 -2
|
@@ -1,62 +0,0 @@
|
|
|
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 input_1 = __importDefault(require("../../../input"));
|
|
9
|
-
const output_1 = __importDefault(require("../../../output"));
|
|
10
|
-
const pipeline_1 = require("../../../types/pipeline");
|
|
11
|
-
const commandPipelineRunApply = (0, utils_1.newCommand)('apply', texts_1.DESC_COMMAND_PIPELINE_RUN_APPLY);
|
|
12
|
-
commandPipelineRunApply.option('-w, --workspace <domain>', texts_1.OPTION_REST_API_WORKSPACE);
|
|
13
|
-
commandPipelineRunApply.option('-p, --project <name>', texts_1.OPTION_REST_API_PROJECT);
|
|
14
|
-
commandPipelineRunApply.option('-n, --no-wait', texts_1.OPTION_PIPELINE_RUN_NO_WAIT);
|
|
15
|
-
commandPipelineRunApply.argument('<identifier>', texts_1.OPTION_PIPELINE_RUN_ARGUMENT);
|
|
16
|
-
commandPipelineRunApply.argument('<run-id>', texts_1.OPTION_PIPELINE_RUN_ID);
|
|
17
|
-
commandPipelineRunApply.argument('<run-action-id>', texts_1.OPTION_PIPELINE_RUN_ACTION_ID);
|
|
18
|
-
commandPipelineRunApply.option('-v,--variable <variables...>', texts_1.OPTION_PIPELINE_RUN_VAR);
|
|
19
|
-
commandPipelineRunApply.addHelpText('after', texts_1.EXAMPLE_PIPELINE_RUN_APPLY);
|
|
20
|
-
commandPipelineRunApply.action(async (identifier, runId, runActionId, options) => {
|
|
21
|
-
const workspace = input_1.default.restApiWorkspace(options.workspace);
|
|
22
|
-
const project = input_1.default.restApiProject(options.project);
|
|
23
|
-
const rid = input_1.default.pipelineRunId(runId);
|
|
24
|
-
const variables = input_1.default.pipelineRunVariable(options.variable || [], false);
|
|
25
|
-
const client = input_1.default.restApiTokenClient();
|
|
26
|
-
const data = await client.getPipelineByIdentifier(workspace, project, identifier);
|
|
27
|
-
if (!data || !data.domain) {
|
|
28
|
-
output_1.default.exitError(texts_1.ERR_WORKSPACE_NOT_FOUND);
|
|
29
|
-
}
|
|
30
|
-
if (!data.project_identifier) {
|
|
31
|
-
output_1.default.exitError(texts_1.ERR_PROJECT_NOT_FOUND);
|
|
32
|
-
}
|
|
33
|
-
if (!data.pipeline_id) {
|
|
34
|
-
output_1.default.exitError(texts_1.ERR_PIPELINE_NOT_FOUND);
|
|
35
|
-
}
|
|
36
|
-
const a = await client.getPipelineRunActionExecution(workspace, project, data.pipeline_id, rid, runActionId);
|
|
37
|
-
let type;
|
|
38
|
-
if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_APPLY) {
|
|
39
|
-
type = 'APPLY';
|
|
40
|
-
}
|
|
41
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VT_SESSION) {
|
|
42
|
-
type = 'APPROVE_VT';
|
|
43
|
-
}
|
|
44
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_VARIABLES) {
|
|
45
|
-
type = 'APPLY_VARIABLES';
|
|
46
|
-
}
|
|
47
|
-
else if (a.status === pipeline_1.PIPELINE_RUN_STATUS.WAITING_FOR_SETTABLE_VARIABLES) {
|
|
48
|
-
type = 'SET_VARIABLES';
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
output_1.default.exitError(texts_1.ERR_CANT_APPLY_ACTION_EXECUTION);
|
|
52
|
-
}
|
|
53
|
-
const body = {
|
|
54
|
-
operation: type,
|
|
55
|
-
approve_action_id: runActionId,
|
|
56
|
-
variables,
|
|
57
|
-
};
|
|
58
|
-
await client.pipelineRunApply(workspace, project, data.pipeline_id, rid, body);
|
|
59
|
-
const OutputPipeline = require('../../../output/pipeline').default;
|
|
60
|
-
await OutputPipeline.runStatus(client, workspace, project, data.pipeline_id, rid, !options.wait);
|
|
61
|
-
});
|
|
62
|
-
exports.default = commandPipelineRunApply;
|
|
@@ -1,66 +0,0 @@
|
|
|
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 commandPrCommentAdd = (0, utils_1.newCommand)('add', texts_1.DESC_COMMAND_PR_COMMENT_ADD, {
|
|
12
|
-
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
13
|
-
examples: texts_1.EXAMPLE_PR_COMMENT_ADD,
|
|
14
|
-
});
|
|
15
|
-
(0, shared_1.addPrOptions)(commandPrCommentAdd, true);
|
|
16
|
-
commandPrCommentAdd.option('-m, --message <text|@path|->', texts_1.OPTION_PR_MESSAGE);
|
|
17
|
-
commandPrCommentAdd.option('--path <path>', texts_1.OPTION_PR_COMMENT_PATH);
|
|
18
|
-
commandPrCommentAdd.option('--new-line <n>', texts_1.OPTION_PR_NEW_LINE);
|
|
19
|
-
commandPrCommentAdd.option('--old-line <n>', texts_1.OPTION_PR_OLD_LINE);
|
|
20
|
-
commandPrCommentAdd.option('--thread <id>', texts_1.OPTION_PR_COMMENT_THREAD);
|
|
21
|
-
commandPrCommentAdd.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
22
|
-
commandPrCommentAdd.action(async (n, options) => {
|
|
23
|
-
const hasLine = options.newLine !== undefined || options.oldLine !== undefined;
|
|
24
|
-
if (options.path && options.thread)
|
|
25
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_COMMENT_MODES);
|
|
26
|
-
if (!options.path && hasLine)
|
|
27
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_COMMENT_LINE_WITHOUT_PATH);
|
|
28
|
-
if (options.path && (options.newLine === undefined) === (options.oldLine === undefined)) {
|
|
29
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_COMMENT_LINE);
|
|
30
|
-
}
|
|
31
|
-
if (!options.path && options.rev !== undefined) {
|
|
32
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_COMMENT_REV_WITHOUT_PATH);
|
|
33
|
-
}
|
|
34
|
-
const newLine = (0, shared_1.parseLine)(options.newLine, '--new-line');
|
|
35
|
-
const oldLine = (0, shared_1.parseLine)(options.oldLine, '--old-line');
|
|
36
|
-
const version = (0, shared_1.parseRev)(options.rev);
|
|
37
|
-
const comment = (0, shared_1.readText)(options.message);
|
|
38
|
-
const json = options.format === 'json';
|
|
39
|
-
const scope = (0, shared_1.prScope)(options);
|
|
40
|
-
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
41
|
-
const { client, workspace, project } = scope;
|
|
42
|
-
if (options.thread) {
|
|
43
|
-
const thread = await client.addPullRequestThreadComment(workspace, project, number, options.thread, comment);
|
|
44
|
-
output_1.default.exitResult(json, thread, (0, texts_1.TXT_PR_THREAD_REPLIED)(options.thread));
|
|
45
|
-
}
|
|
46
|
-
if (options.path) {
|
|
47
|
-
const thread = await client.addPullRequestThread(workspace, project, number, {
|
|
48
|
-
path: options.path,
|
|
49
|
-
new_line: newLine,
|
|
50
|
-
old_line: oldLine,
|
|
51
|
-
comment,
|
|
52
|
-
version,
|
|
53
|
-
});
|
|
54
|
-
if (json)
|
|
55
|
-
output_1.default.exitResult(true, thread);
|
|
56
|
-
const opened = thread.created_version ?? thread.position?.version ?? version;
|
|
57
|
-
if (version) {
|
|
58
|
-
const pr = await client.getPullRequest(workspace, project, number);
|
|
59
|
-
(0, shared_1.noteVersionBehind)(pr?.version, version);
|
|
60
|
-
}
|
|
61
|
-
output_1.default.exitSuccess((0, texts_1.TXT_PR_THREAD_ADDED)(thread.id, (0, shared_1.positionText)(thread.position), opened));
|
|
62
|
-
}
|
|
63
|
-
const result = await client.addPullRequestComment(workspace, project, number, comment);
|
|
64
|
-
output_1.default.exitResult(json, result, texts_1.TXT_PR_COMMENT_ADDED);
|
|
65
|
-
});
|
|
66
|
-
exports.default = commandPrCommentAdd;
|
|
@@ -1,169 +0,0 @@
|
|
|
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 commandPrCommentList = (0, utils_1.newCommand)('list', texts_1.DESC_COMMAND_PR_COMMENT_LIST, {
|
|
13
|
-
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_READ],
|
|
14
|
-
examples: texts_1.EXAMPLE_PR_COMMENT_LIST,
|
|
15
|
-
});
|
|
16
|
-
commandPrCommentList.alias('ls');
|
|
17
|
-
(0, shared_1.addPrOptions)(commandPrCommentList, true);
|
|
18
|
-
commandPrCommentList.option('--since-review', texts_1.OPTION_PR_COMMENT_SINCE_REVIEW);
|
|
19
|
-
commandPrCommentList.option('--threads', texts_1.OPTION_PR_COMMENT_THREADS);
|
|
20
|
-
commandPrCommentList.option('--thread <id>', texts_1.OPTION_PR_COMMENT_THREAD);
|
|
21
|
-
commandPrCommentList.option('--status <status>', texts_1.OPTION_PR_THREAD_STATUS);
|
|
22
|
-
commandPrCommentList.option('--path <path>', texts_1.OPTION_PR_THREAD_PATH);
|
|
23
|
-
commandPrCommentList.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
24
|
-
const printMessage = (who, date, text, indent) => {
|
|
25
|
-
const lines = (text || '').split('\n');
|
|
26
|
-
output_1.default.normal(`${indent}${(0, shared_1.memberName)(who)} (${(0, shared_1.formatDate)(date)}): ${lines[0]}`);
|
|
27
|
-
lines.slice(1).forEach((line) => output_1.default.normal(`${indent} ${line}`));
|
|
28
|
-
};
|
|
29
|
-
/** The full diff of every path the threads sit on, parsed, for the code around a thread. */
|
|
30
|
-
const patchesOf = async (scope, number, version, threads) => {
|
|
31
|
-
const paths = [...new Set(threads.map((t) => t.position?.path).filter(Boolean))];
|
|
32
|
-
const result = new Map();
|
|
33
|
-
await Promise.all(paths.map(async (path) => {
|
|
34
|
-
try {
|
|
35
|
-
const diff = await scope.client.getPullRequestDiff(scope.workspace, scope.project, number, {
|
|
36
|
-
path,
|
|
37
|
-
version,
|
|
38
|
-
full: true,
|
|
39
|
-
});
|
|
40
|
-
result.set(path, (0, shared_1.parsePatch)(diff?.patch));
|
|
41
|
-
}
|
|
42
|
-
catch {
|
|
43
|
-
result.set(path, []);
|
|
44
|
-
}
|
|
45
|
-
}));
|
|
46
|
-
return result;
|
|
47
|
-
};
|
|
48
|
-
const listActivity = async (scope, number, options) => {
|
|
49
|
-
const since = options.sinceReview
|
|
50
|
-
? (await (0, shared_1.requireMyReview)(scope, number)).last_update_date
|
|
51
|
-
: undefined;
|
|
52
|
-
const result = await scope.client.getPullRequestActivity(scope.workspace, scope.project, number, since);
|
|
53
|
-
const activities = result?.activities || [];
|
|
54
|
-
if (options.format === 'json') {
|
|
55
|
-
output_1.default.json(activities);
|
|
56
|
-
output_1.default.exitNormal();
|
|
57
|
-
}
|
|
58
|
-
if (activities.length === 0)
|
|
59
|
-
output_1.default.exitNormal(texts_1.TXT_PR_ACTIVITY_NOT_FOUND);
|
|
60
|
-
for (const entry of activities) {
|
|
61
|
-
// the line says what happened; a comment then follows in full
|
|
62
|
-
output_1.default.normal((0, summary_1.activityLine)(entry));
|
|
63
|
-
if (entry.type === utils_1.PR_ACTIVITY_TYPE.COMMENT) {
|
|
64
|
-
(entry.comment || '').split('\n').slice(1).forEach((line) => output_1.default.normal(` ${line}`));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
output_1.default.exitNormal();
|
|
68
|
-
};
|
|
69
|
-
const listThreads = async (scope, number, version, options) => {
|
|
70
|
-
let status;
|
|
71
|
-
if (options.status) {
|
|
72
|
-
status = String(options.status).toUpperCase();
|
|
73
|
-
if (!Object.values(utils_1.PR_THREAD_STATUS).includes(status)) {
|
|
74
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_THREAD_STATUS);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
const result = await (0, shared_1.fetchAllThreads)(scope, number, {
|
|
78
|
-
version,
|
|
79
|
-
status,
|
|
80
|
-
path: options.path,
|
|
81
|
-
});
|
|
82
|
-
const threads = result.threads || [];
|
|
83
|
-
if (options.format === 'json') {
|
|
84
|
-
output_1.default.json(threads);
|
|
85
|
-
output_1.default.exitNormal();
|
|
86
|
-
}
|
|
87
|
-
const shown = result.version ?? version;
|
|
88
|
-
if (version) {
|
|
89
|
-
const pr = await scope.client.getPullRequest(scope.workspace, scope.project, number);
|
|
90
|
-
(0, shared_1.noteVersionBehind)(pr?.version, shown);
|
|
91
|
-
}
|
|
92
|
-
if (threads.length === 0)
|
|
93
|
-
output_1.default.exitNormal(texts_1.TXT_PR_THREADS_NOT_FOUND);
|
|
94
|
-
const [patches, origins] = await Promise.all([
|
|
95
|
-
patchesOf(scope, number, shown, threads),
|
|
96
|
-
Promise.all(threads.map((t) => (0, shared_1.threadOrigin)(scope, number, t))),
|
|
97
|
-
]);
|
|
98
|
-
threads.forEach((thread, index) => {
|
|
99
|
-
output_1.default.normal((0, shared_1.threadHeader)(thread));
|
|
100
|
-
const origin = origins[index];
|
|
101
|
-
if (origin)
|
|
102
|
-
output_1.default.muted(` ${(0, texts_1.TXT_PR_MOVED_FROM)((0, shared_1.positionText)(origin))}`);
|
|
103
|
-
output_1.default.muted(` opened in v${thread.created_version}`);
|
|
104
|
-
printMessage(thread.author, thread.create_date, thread.comment, ' ');
|
|
105
|
-
const replies = thread.comments || [];
|
|
106
|
-
if (replies.length > 0) {
|
|
107
|
-
const last = replies[replies.length - 1];
|
|
108
|
-
printMessage(last.user, last.create_date, last.comment, ' ');
|
|
109
|
-
if (replies.length > 1)
|
|
110
|
-
output_1.default.muted(` … ${replies.length} replies: ${scope.cmd(`comment ls ${number} --thread ${thread.id} --rev v${shown}`)}`);
|
|
111
|
-
}
|
|
112
|
-
const code = (0, shared_1.codeAround)(patches.get(thread.position?.path) || [], thread.position);
|
|
113
|
-
code.forEach((line) => output_1.default.normal(` ${line.type === 'meta' ? line.text : (0, shared_1.formatPatchLine)(line)}`));
|
|
114
|
-
const duplicates = thread.duplicates || [];
|
|
115
|
-
if (duplicates.length > 0) {
|
|
116
|
-
output_1.default.muted(` ${(0, texts_1.TXT_PR_SAME_CHANGE)(duplicates.map((d) => `${d.path}:${d.new_start}`).join(', '))}`);
|
|
117
|
-
}
|
|
118
|
-
output_1.default.newline();
|
|
119
|
-
});
|
|
120
|
-
output_1.default.exitNormal();
|
|
121
|
-
};
|
|
122
|
-
const showThread = async (scope, number, id, version, options) => {
|
|
123
|
-
const thread = await scope.client.getPullRequestThread(scope.workspace, scope.project, number, id, version);
|
|
124
|
-
if (options.format === 'json') {
|
|
125
|
-
output_1.default.json(thread);
|
|
126
|
-
output_1.default.exitNormal();
|
|
127
|
-
}
|
|
128
|
-
output_1.default.normal((0, shared_1.threadHeader)(thread));
|
|
129
|
-
const origin = await (0, shared_1.threadOrigin)(scope, number, thread);
|
|
130
|
-
if (origin)
|
|
131
|
-
output_1.default.muted(` ${(0, texts_1.TXT_PR_MOVED_FROM)((0, shared_1.positionText)(origin))}`);
|
|
132
|
-
output_1.default.muted(` opened in v${thread.created_version}, position in v${thread.position?.version ?? version ?? '-'}`);
|
|
133
|
-
printMessage(thread.author, thread.create_date, thread.comment, ' ');
|
|
134
|
-
for (const reply of thread.comments || []) {
|
|
135
|
-
printMessage(reply.user, reply.create_date, reply.comment, ' ');
|
|
136
|
-
}
|
|
137
|
-
const events = thread.events || [];
|
|
138
|
-
if (events.length > 0) {
|
|
139
|
-
output_1.default.newline();
|
|
140
|
-
output_1.default.label('Status history');
|
|
141
|
-
for (const event of events) {
|
|
142
|
-
output_1.default.normal(` ${(0, shared_1.formatDate)(event.create_date)} ${(0, shared_1.memberName)(event.user)}: ${(0, shared_1.threadStatusText)(event.from)} → ${(0, shared_1.threadStatusWithResolution)(event.to, event.resolution)}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
output_1.default.exitNormal();
|
|
146
|
-
};
|
|
147
|
-
commandPrCommentList.action(async (n, options) => {
|
|
148
|
-
if (options.threads && options.thread)
|
|
149
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_LIST_MODES);
|
|
150
|
-
if (!options.threads && (options.status || options.path)) {
|
|
151
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_LIST_THREAD_OPTIONS);
|
|
152
|
-
}
|
|
153
|
-
if (options.sinceReview && (options.threads || options.thread)) {
|
|
154
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_LIST_SINCE_REVIEW_THREADS);
|
|
155
|
-
}
|
|
156
|
-
if (options.rev !== undefined && !options.threads && !options.thread) {
|
|
157
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_LIST_REV);
|
|
158
|
-
}
|
|
159
|
-
const version = (0, shared_1.parseRev)(options.rev);
|
|
160
|
-
const scope = (0, shared_1.prScope)(options);
|
|
161
|
-
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
162
|
-
if (options.thread)
|
|
163
|
-
await showThread(scope, number, options.thread, version, options);
|
|
164
|
-
else if (options.threads)
|
|
165
|
-
await listThreads(scope, number, version, options);
|
|
166
|
-
else
|
|
167
|
-
await listActivity(scope, number, options);
|
|
168
|
-
});
|
|
169
|
-
exports.default = commandPrCommentList;
|
|
@@ -1,48 +0,0 @@
|
|
|
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.commandPrCommentReopen = exports.commandPrCommentClose = exports.commandPrCommentResolve = 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
|
-
/** fixed | by_design | wontfix (any case, `-` for `_`) -> FIXED | BY_DESIGN | WONTFIX */
|
|
13
|
-
const parseReason = (value) => {
|
|
14
|
-
if (value === undefined)
|
|
15
|
-
return undefined;
|
|
16
|
-
const reason = value.trim().toUpperCase().replace(/-/g, '_');
|
|
17
|
-
if (!Object.values(utils_1.PR_THREAD_RESOLUTION).includes(reason)) {
|
|
18
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_REASON);
|
|
19
|
-
}
|
|
20
|
-
return reason;
|
|
21
|
-
};
|
|
22
|
-
const statusCommand = (name, description, examples, status, withReason) => {
|
|
23
|
-
const command = (0, utils_1.newCommand)(name, description, {
|
|
24
|
-
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
25
|
-
examples,
|
|
26
|
-
});
|
|
27
|
-
(0, shared_1.addPrOptions)(command);
|
|
28
|
-
command.option('--thread <id>', texts_1.OPTION_PR_COMMENT_THREAD);
|
|
29
|
-
if (withReason)
|
|
30
|
-
command.option('--reason <reason>', texts_1.OPTION_PR_REASON);
|
|
31
|
-
command.option('-m, --message <text|@path|->', texts_1.OPTION_PR_MESSAGE);
|
|
32
|
-
command.argument('[N]', texts_1.OPTION_PR_NUMBER);
|
|
33
|
-
command.action(async (n, options) => {
|
|
34
|
-
if (!options.thread)
|
|
35
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_THREAD_REQUIRED);
|
|
36
|
-
const resolution = withReason ? parseReason(options.reason) : undefined;
|
|
37
|
-
const comment = (0, shared_1.readText)(options.message, false);
|
|
38
|
-
const scope = (0, shared_1.prScope)(options);
|
|
39
|
-
const number = await (0, shared_1.resolveNumber)(scope, n);
|
|
40
|
-
const thread = await scope.client.updatePullRequestThread(scope.workspace, scope.project, number, options.thread, { status, resolution, comment });
|
|
41
|
-
const state = thread?.resolution ? `${thread.status} (${thread.resolution})` : (thread?.status ?? status);
|
|
42
|
-
output_1.default.exitResult(options.format === 'json', thread, (0, texts_1.TXT_PR_THREAD_STATUS)(options.thread, state));
|
|
43
|
-
});
|
|
44
|
-
return command;
|
|
45
|
-
};
|
|
46
|
-
exports.commandPrCommentResolve = statusCommand('resolve', texts_1.DESC_COMMAND_PR_COMMENT_RESOLVE, texts_1.EXAMPLE_PR_COMMENT_RESOLVE, utils_1.PR_THREAD_STATUS.RESOLVED, true);
|
|
47
|
-
exports.commandPrCommentClose = statusCommand('close', texts_1.DESC_COMMAND_PR_COMMENT_CLOSE, texts_1.EXAMPLE_PR_COMMENT_CLOSE, utils_1.PR_THREAD_STATUS.CLOSED, true);
|
|
48
|
-
exports.commandPrCommentReopen = statusCommand('reopen', texts_1.DESC_COMMAND_PR_COMMENT_REOPEN, texts_1.EXAMPLE_PR_COMMENT_REOPEN, utils_1.PR_THREAD_STATUS.OPEN, false);
|
|
@@ -1,19 +0,0 @@
|
|
|
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("./comment/list"));
|
|
9
|
-
const add_1 = __importDefault(require("./comment/add"));
|
|
10
|
-
const status_1 = require("./comment/status");
|
|
11
|
-
const commandPrComment = (0, utils_1.newCommand)('comment', texts_1.DESC_COMMAND_PR_COMMENT, {
|
|
12
|
-
examples: texts_1.EXAMPLE_PR_COMMENT,
|
|
13
|
-
});
|
|
14
|
-
commandPrComment.addCommand(list_1.default);
|
|
15
|
-
commandPrComment.addCommand(add_1.default);
|
|
16
|
-
commandPrComment.addCommand(status_1.commandPrCommentResolve);
|
|
17
|
-
commandPrComment.addCommand(status_1.commandPrCommentClose);
|
|
18
|
-
commandPrComment.addCommand(status_1.commandPrCommentReopen);
|
|
19
|
-
exports.default = commandPrComment;
|
|
@@ -1,43 +0,0 @@
|
|
|
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 commandPrCreate = (0, utils_1.newCommand)('create', texts_1.DESC_COMMAND_PR_CREATE, {
|
|
12
|
-
requiredScopes: [utils_1.REST_API_SCOPE.REPOSITORY_WRITE],
|
|
13
|
-
examples: texts_1.EXAMPLE_PR_CREATE,
|
|
14
|
-
});
|
|
15
|
-
commandPrCreate.alias('add');
|
|
16
|
-
(0, shared_1.addPrOptions)(commandPrCreate);
|
|
17
|
-
commandPrCreate.requiredOption('-B, --base <branch>', texts_1.OPTION_PR_CREATE_BASE);
|
|
18
|
-
commandPrCreate.option('-H, --head <branch>', texts_1.OPTION_PR_CREATE_HEAD);
|
|
19
|
-
commandPrCreate.requiredOption('-t, --title <title>', texts_1.OPTION_PR_TITLE);
|
|
20
|
-
commandPrCreate.option('-m, --message <text|@path|->', texts_1.OPTION_PR_DESCRIPTION);
|
|
21
|
-
commandPrCreate.option('--draft', texts_1.OPTION_PR_DRAFT);
|
|
22
|
-
commandPrCreate.option('--label <labels...>', texts_1.OPTION_PR_LABEL);
|
|
23
|
-
commandPrCreate.option('--reviewer <logins...>', texts_1.OPTION_PR_CREATE_REVIEWER);
|
|
24
|
-
commandPrCreate.option('--assignee <logins...>', texts_1.OPTION_PR_ASSIGNEE);
|
|
25
|
-
commandPrCreate.action(async (options) => {
|
|
26
|
-
const head = options.head || (0, shared_1.currentGitBranch)();
|
|
27
|
-
if (!head)
|
|
28
|
-
throw new cliError_1.default('usage_error', texts_1.ERR_PR_NO_HEAD);
|
|
29
|
-
const description = (0, shared_1.readText)(options.message, false);
|
|
30
|
-
const scope = (0, shared_1.prScope)(options);
|
|
31
|
-
const pr = await scope.client.createPullRequest(scope.workspace, scope.project, {
|
|
32
|
-
base: options.base,
|
|
33
|
-
head,
|
|
34
|
-
title: options.title,
|
|
35
|
-
description,
|
|
36
|
-
draft: options.draft ? true : undefined,
|
|
37
|
-
labels: options.label,
|
|
38
|
-
reviewers: options.reviewer,
|
|
39
|
-
assignees: options.assignee,
|
|
40
|
-
});
|
|
41
|
-
output_1.default.exitResult(options.format === 'json', pr, (0, texts_1.TXT_PR_CREATED)(pr.number, pr.version ?? 1));
|
|
42
|
-
});
|
|
43
|
-
exports.default = commandPrCreate;
|
|
@@ -1,227 +0,0 @@
|
|
|
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;
|