gcb-client 0.7.1 → 0.8.0
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/CHANGELOG.md +16 -2
- package/bin/gcb.js +6 -6
- package/lib/commands/gh.d.ts +3 -3
- package/lib/commands/gh.d.ts.map +1 -1
- package/lib/commands/gh.js +95 -47
- package/lib/commands/gh.js.map +1 -1
- package/lib/commands/host-submit.d.ts +8 -8
- package/lib/commands/host-submit.d.ts.map +1 -1
- package/lib/commands/host-submit.js +32 -22
- package/lib/commands/host-submit.js.map +1 -1
- package/lib/commands/logs.d.ts +2 -2
- package/lib/commands/logs.d.ts.map +1 -1
- package/lib/commands/logs.js +17 -11
- package/lib/commands/logs.js.map +1 -1
- package/lib/commands/pr.d.ts +2 -2
- package/lib/commands/pr.d.ts.map +1 -1
- package/lib/commands/pr.js +186 -69
- package/lib/commands/pr.js.map +1 -1
- package/lib/commands/probe.d.ts +2 -2
- package/lib/commands/probe.d.ts.map +1 -1
- package/lib/commands/probe.js +19 -13
- package/lib/commands/probe.js.map +1 -1
- package/lib/commands/remotes.d.ts +24 -21
- package/lib/commands/remotes.d.ts.map +1 -1
- package/lib/commands/remotes.js +71 -53
- package/lib/commands/remotes.js.map +1 -1
- package/lib/commands/repo.d.ts.map +1 -1
- package/lib/commands/repo.js +26 -16
- package/lib/commands/repo.js.map +1 -1
- package/lib/commands/setup.d.ts +7 -7
- package/lib/commands/setup.d.ts.map +1 -1
- package/lib/commands/setup.js +38 -27
- package/lib/commands/setup.js.map +1 -1
- package/lib/helper.d.ts +27 -27
- package/lib/helper.d.ts.map +1 -1
- package/lib/helper.js +82 -66
- package/lib/helper.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -8
- package/lib/index.js.map +1 -1
- package/lib/primary.d.ts +5 -5
- package/lib/primary.d.ts.map +1 -1
- package/lib/primary.js +5 -5
- package/lib/primary.js.map +1 -1
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-submit.js","sourceRoot":"","sources":["../../src/commands/host-submit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"host-submit.js","sourceRoot":"","sources":["../../src/commands/host-submit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,eAAe,EACf,aAAa,EACb,YAAY,EACZ,IAAI,EACJ,WAAW,EACX,GAAG,GACJ,MAAM,UAAU,CAAA;AAGjB;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,EAAU,EAAE,IAAY,EAAE,SAAiB;IACtF,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC,CAAA;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC,CAAA;IAC3D,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QACzB,OAAO,CACL,wBAAwB,EAAE,qCAAqC;YAC/D,qCAAqC,IAAI,kDAAkD,CAC5F,CAAA;IACH,CAAC;IACD,MAAM,OAAO,GAAG,SAAS,IAAI,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,CAAA;IAC3F,OAAO,CACL,kCAAkC,EAAE,WAAW,OAAO,IAAI;QAC1D,qGAAqG;QACrG,wBAAwB,IAAI,yBAAyB,IAAI,4BAA4B,CACtF,CAAA;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|
-
* @returns
|
|
6
|
+
* @param argv - Arguments after the command name.
|
|
7
|
+
* @returns The process exit code: 0 read, 1 refused, 3 unreachable.
|
|
8
8
|
*/
|
|
9
9
|
export declare function runLogs(argv: readonly string[]): Promise<number>;
|
|
10
10
|
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAqBA,6BAA6B;AAC7B,eAAO,MAAM,UAAU,4lBAWtB,CAAA;AAED;;;;;GAKG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAyEtE"}
|
package/lib/commands/logs.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { fail, parseArgs, say } from 'gcb-core';
|
|
1
2
|
/**
|
|
2
3
|
* `logs` — read one workflow job's log through the broker.
|
|
3
4
|
*
|
|
4
5
|
* The credential never leaves the broker. The broker mints a read-only, single-repository token
|
|
5
|
-
* narrowed to `actions: read`, fetches the log itself, and answers with the text: the agent gets
|
|
6
|
-
* log without ever holding something that could read anything else.
|
|
6
|
+
* narrowed to `actions: read`, fetches the log itself, and answers with the text: the agent gets
|
|
7
|
+
* the log without ever holding something that could read anything else.
|
|
7
8
|
*
|
|
8
9
|
* Exit codes: 0 read, 1 refused, 3 broker unreachable.
|
|
9
10
|
*/
|
|
10
11
|
import { requestOverSocket, resolveSocketPath } from '../helper.js';
|
|
11
|
-
import { fail, parseArgs, say } from 'gcb-core';
|
|
12
12
|
/**
|
|
13
13
|
* How long to wait for the broker.
|
|
14
14
|
*
|
|
@@ -32,15 +32,17 @@ Read a workflow job log through the broker, without the credential ever reaching
|
|
|
32
32
|
/**
|
|
33
33
|
* Run the `logs` command.
|
|
34
34
|
*
|
|
35
|
-
* @param argv -
|
|
36
|
-
* @returns
|
|
35
|
+
* @param argv - Arguments after the command name.
|
|
36
|
+
* @returns The process exit code: 0 read, 1 refused, 3 unreachable.
|
|
37
37
|
*/
|
|
38
38
|
export async function runLogs(argv) {
|
|
39
39
|
const args = parseArgs(argv, { booleans: ['help', 'no-proxy'] });
|
|
40
|
-
if (args.has('no-proxy') && args.value('proxy') !== undefined)
|
|
40
|
+
if (args.has('no-proxy') && args.value('proxy') !== undefined) {
|
|
41
41
|
fail('--proxy and --no-proxy are mutually exclusive');
|
|
42
|
-
|
|
42
|
+
}
|
|
43
|
+
if (args.has('proxy') && args.value('proxy') === undefined) {
|
|
43
44
|
fail('--proxy needs a value');
|
|
45
|
+
}
|
|
44
46
|
const proxy = args.has('no-proxy') ? null : args.value('proxy');
|
|
45
47
|
if (args.has('help') || args.has('h')) {
|
|
46
48
|
say(LOGS_USAGE);
|
|
@@ -48,20 +50,24 @@ export async function runLogs(argv) {
|
|
|
48
50
|
}
|
|
49
51
|
const socketPath = resolveSocketPath(args.value('socket'), process.env);
|
|
50
52
|
const hostArg = args.value('host');
|
|
51
|
-
if (args.has('host') && hostArg === undefined)
|
|
53
|
+
if (args.has('host') && hostArg === undefined) {
|
|
52
54
|
fail('--host needs a value');
|
|
53
|
-
|
|
55
|
+
}
|
|
56
|
+
if (hostArg === '') {
|
|
54
57
|
fail('--host needs a value');
|
|
58
|
+
}
|
|
55
59
|
const host = hostArg ?? 'github.com';
|
|
56
60
|
const repo = args.value('repo');
|
|
57
61
|
const rawJob = args.value('job');
|
|
58
62
|
if (!socketPath) {
|
|
59
63
|
fail('no broker socket: pass --socket, set GIT_BROKER_SOCKET, or run `gcb setup`');
|
|
60
64
|
}
|
|
61
|
-
if (!repo)
|
|
65
|
+
if (!repo) {
|
|
62
66
|
fail('--repo is required (e.g. owner/name)');
|
|
63
|
-
|
|
67
|
+
}
|
|
68
|
+
if (!rawJob) {
|
|
64
69
|
fail('--job is required (the workflow job id, which is also the check run id)');
|
|
70
|
+
}
|
|
65
71
|
const jobId = Number(rawJob);
|
|
66
72
|
if (!Number.isInteger(jobId) || jobId <= 0) {
|
|
67
73
|
fail(`--job must be a positive integer, got ${JSON.stringify(rawJob)}`);
|
package/lib/commands/logs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAE/C;;;;;;;;GAQG;AACH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEnE;;;;;GAKG;AACH,MAAM,eAAe,GAAG,MAAM,CAAA;AAE9B,6BAA6B;AAC7B,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;;;;;;;CAWzB,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAAC,IAAuB;IACnD,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,CAAA;IAChE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE,CAAC;QAC9D,IAAI,CAAC,+CAA+C,CAAC,CAAA;IACvD,CAAC;IACD,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,SAAS,EAAE,CAAC;QAC3D,IAAI,CAAC,uBAAuB,CAAC,CAAA;IAC/B,CAAC;IACD,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAA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cb pr [options]\n\nOpen, update or insp
|
|
|
3
3
|
/**
|
|
4
4
|
* Run the `pr` command.
|
|
5
5
|
*
|
|
6
|
-
* @param argv -
|
|
7
|
-
* @returns
|
|
6
|
+
* @param argv - Arguments after the command name.
|
|
7
|
+
* @returns The process exit code: 0 done, 1 refused, 3 unreachable.
|
|
8
8
|
*/
|
|
9
9
|
export declare function runPr(argv: readonly string[]): Promise<number>;
|
|
10
10
|
//# sourceMappingURL=pr.d.ts.map
|
package/lib/commands/pr.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../../src/commands/pr.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pr.d.ts","sourceRoot":"","sources":["../../src/commands/pr.ts"],"names":[],"mappings":"AAyDA,2BAA2B;AAC3B,eAAO,MAAM,QAAQ,28GAsDpB,CAAA;AA6CD;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAghBpE"}
|
package/lib/commands/pr.js
CHANGED
|
@@ -1,28 +1,53 @@
|
|
|
1
|
+
import { LOGIN, bodyFromArgs, fail, parseArgs, say, validateArgs } from 'gcb-core';
|
|
1
2
|
/**
|
|
2
3
|
* `pr` — open, update or inspect one pull request through the broker.
|
|
3
4
|
*
|
|
4
5
|
* `pr <subcommand>` runs as the catalogued gh action when the catalog has one (`pr:view`,
|
|
5
6
|
* `pr:close`, …); this file is the flag-only lifecycle for the actions gh cannot express.
|
|
6
7
|
*
|
|
7
|
-
* The credential never leaves the broker. The broker mints a token narrowed to `pull_requests:
|
|
8
|
-
* plus read access to the branches it names, performs the action itself, and answers with
|
|
9
|
-
* the URL and the state: the agent gets the lifecycle of a pull request without ever
|
|
10
|
-
* something that could push to it.
|
|
8
|
+
* The credential never leaves the broker. The broker mints a token narrowed to `pull_requests:
|
|
9
|
+
* write` plus read access to the branches it names, performs the action itself, and answers with
|
|
10
|
+
* the number, the URL and the state: the agent gets the lifecycle of a pull request without ever
|
|
11
|
+
* holding something that could push to it.
|
|
11
12
|
*
|
|
12
13
|
* Exit codes: 0 done, 1 refused, 3 broker unreachable.
|
|
13
14
|
*/
|
|
14
|
-
import { LOGIN } from 'gcb-core';
|
|
15
15
|
import { requestOverSocket, resolveSocketPath } from '../helper.js';
|
|
16
|
-
import { baseBranchFor, qualifiedBranch, remoteRepo } from './remotes.js';
|
|
17
16
|
import { runGh } from './gh.js';
|
|
18
17
|
import { submitToHostBroker } from './host-submit.js';
|
|
19
|
-
import {
|
|
18
|
+
import { baseBranchFor, qualifiedBranch, remoteRepo } from './remotes.js';
|
|
20
19
|
/** Every flag the flag-only lifecycle understands. */
|
|
21
20
|
const KNOWN_FLAGS = new Set([
|
|
22
|
-
'help',
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
21
|
+
'help',
|
|
22
|
+
'h',
|
|
23
|
+
'draft',
|
|
24
|
+
'close',
|
|
25
|
+
'comment',
|
|
26
|
+
'file',
|
|
27
|
+
'line',
|
|
28
|
+
'side',
|
|
29
|
+
'threads',
|
|
30
|
+
'reply-to',
|
|
31
|
+
'edit',
|
|
32
|
+
'resolve',
|
|
33
|
+
'id',
|
|
34
|
+
'jq',
|
|
35
|
+
'proxy',
|
|
36
|
+
'no-proxy',
|
|
37
|
+
'socket',
|
|
38
|
+
'host',
|
|
39
|
+
'repo',
|
|
40
|
+
'head',
|
|
41
|
+
'base',
|
|
42
|
+
'title',
|
|
43
|
+
'body',
|
|
44
|
+
'body-file',
|
|
45
|
+
'number',
|
|
46
|
+
'as-user',
|
|
47
|
+
'status',
|
|
48
|
+
'approve',
|
|
49
|
+
'request-changes',
|
|
50
|
+
'review-comment',
|
|
26
51
|
]);
|
|
27
52
|
/** Longer than a credential request: a token is minted, then the action is performed. */
|
|
28
53
|
const PR_TIMEOUT_MS = 60_000;
|
|
@@ -87,8 +112,8 @@ const isPositiveSafeInteger = (value) => value !== undefined && /^[1-9][0-9]*$/.
|
|
|
87
112
|
/**
|
|
88
113
|
* Read the action out of the flags.
|
|
89
114
|
*
|
|
90
|
-
* @param args -
|
|
91
|
-
* @returns
|
|
115
|
+
* @param args - The parsed arguments.
|
|
116
|
+
* @returns The selected action; `--id` is applied by the caller as `review`.
|
|
92
117
|
*/
|
|
93
118
|
function actionOf(args) {
|
|
94
119
|
// `--resolve`, `--reply-to` and `--edit` take a value, and a bare one is parsed as a boolean flag with
|
|
@@ -96,41 +121,60 @@ function actionOf(args) {
|
|
|
96
121
|
// below — reading only `value` let a bare `--edit` fall through to `update`, which patched the pull
|
|
97
122
|
// request itself with the body meant for the comment.
|
|
98
123
|
const present = (name) => args.has(name) || args.value(name) !== undefined;
|
|
99
|
-
if (args.has('approve') || args.has('request-changes') || args.has('review-comment'))
|
|
124
|
+
if (args.has('approve') || args.has('request-changes') || args.has('review-comment')) {
|
|
100
125
|
return 'submit-review';
|
|
101
|
-
|
|
126
|
+
}
|
|
127
|
+
if (present('resolve')) {
|
|
102
128
|
return 'resolve';
|
|
103
|
-
|
|
129
|
+
}
|
|
130
|
+
if (present('reply-to')) {
|
|
104
131
|
return 'reply';
|
|
105
|
-
|
|
132
|
+
}
|
|
133
|
+
if (present('edit')) {
|
|
106
134
|
return 'edit';
|
|
107
|
-
|
|
135
|
+
}
|
|
136
|
+
if (args.has('threads')) {
|
|
108
137
|
return 'threads';
|
|
109
|
-
|
|
138
|
+
}
|
|
139
|
+
if (args.has('comment')) {
|
|
110
140
|
return 'comment';
|
|
111
|
-
|
|
141
|
+
}
|
|
142
|
+
if (args.has('status')) {
|
|
112
143
|
return 'status';
|
|
113
|
-
|
|
144
|
+
}
|
|
145
|
+
if (args.value('number') !== undefined) {
|
|
114
146
|
return 'update';
|
|
147
|
+
}
|
|
115
148
|
return 'open';
|
|
116
149
|
}
|
|
117
150
|
/**
|
|
118
151
|
* Run the `pr` command.
|
|
119
152
|
*
|
|
120
|
-
* @param argv -
|
|
121
|
-
* @returns
|
|
153
|
+
* @param argv - Arguments after the command name.
|
|
154
|
+
* @returns The process exit code: 0 done, 1 refused, 3 unreachable.
|
|
122
155
|
*/
|
|
123
156
|
export async function runPr(argv) {
|
|
124
157
|
const args = parseArgs(argv, {
|
|
125
|
-
booleans: [
|
|
158
|
+
booleans: [
|
|
159
|
+
'help',
|
|
160
|
+
'draft',
|
|
161
|
+
'status',
|
|
162
|
+
'comment',
|
|
163
|
+
'threads',
|
|
164
|
+
'no-proxy',
|
|
165
|
+
'approve',
|
|
166
|
+
'request-changes',
|
|
167
|
+
'review-comment',
|
|
168
|
+
],
|
|
126
169
|
optionalValues: ['as-user', 'close'],
|
|
127
170
|
});
|
|
128
171
|
if (validateArgs(args, argv, KNOWN_FLAGS, 'gcb pr')) {
|
|
129
172
|
say(PR_USAGE);
|
|
130
173
|
return 0;
|
|
131
174
|
}
|
|
132
|
-
if (args.positionals.length > 0)
|
|
175
|
+
if (args.positionals.length > 0) {
|
|
133
176
|
fail('unexpected argument ' + JSON.stringify(args.positionals[0]) + ' for gcb pr');
|
|
177
|
+
}
|
|
134
178
|
// Before --repo: the point of the message is to name the command that does it now.
|
|
135
179
|
if (args.has('close') || args.value('close') !== undefined) {
|
|
136
180
|
fail('--close moved to: gcb gh pr close <number> --repo owner/name');
|
|
@@ -150,45 +194,67 @@ export async function runPr(argv) {
|
|
|
150
194
|
const proxy = args.has('no-proxy') ? null : args.value('proxy');
|
|
151
195
|
const socketPath = resolveSocketPath(args.value('socket'), process.env);
|
|
152
196
|
const looksLikeOption = (value) => value.startsWith('--') || /^-(?=[A-Za-z])/.test(value);
|
|
153
|
-
const invalidValue = (name) => args.has(name) || args.values(name).some(
|
|
197
|
+
const invalidValue = (name) => args.has(name) || args.values(name).some(value => value.trim() === '' || looksLikeOption(value));
|
|
154
198
|
const hasValue = (name) => args.has(name) || args.values(name).length > 0;
|
|
155
199
|
const hostArg = args.value('host');
|
|
156
|
-
if (hasValue('host') && invalidValue('host'))
|
|
200
|
+
if (hasValue('host') && invalidValue('host')) {
|
|
157
201
|
fail('--host needs a value (e.g. github.com)');
|
|
202
|
+
}
|
|
158
203
|
const host = hostArg ?? 'github.com';
|
|
159
204
|
const repoArg = args.value('repo');
|
|
160
|
-
if (hasValue('repo') && invalidValue('repo'))
|
|
205
|
+
if (hasValue('repo') && invalidValue('repo')) {
|
|
161
206
|
fail('--repo needs a value (e.g. owner/name)');
|
|
207
|
+
}
|
|
162
208
|
let repo = repoArg;
|
|
163
209
|
if (repo === undefined) {
|
|
164
210
|
const found = remoteRepo('origin', process.cwd());
|
|
165
|
-
if (found === undefined)
|
|
211
|
+
if (found === undefined) {
|
|
166
212
|
fail('--repo is required when the checkout has no usable origin remote');
|
|
213
|
+
}
|
|
167
214
|
if (found.host !== host.toLowerCase()) {
|
|
168
215
|
fail(`the checkout's remote is on ${found.host}, but --host is ${host}; pass --repo or --host`);
|
|
169
216
|
}
|
|
170
217
|
repo = `${found.owner}/${found.repo}`;
|
|
171
218
|
}
|
|
172
|
-
if (repo.trim() === '')
|
|
219
|
+
if (repo.trim() === '') {
|
|
173
220
|
fail('--repo needs a value (e.g. owner/name)');
|
|
221
|
+
}
|
|
174
222
|
let action = actionOf(args);
|
|
175
223
|
const hasReviewId = args.has('id') || args.value('id') !== undefined;
|
|
176
224
|
if (hasReviewId) {
|
|
177
225
|
const conflicts = [
|
|
178
|
-
'status',
|
|
179
|
-
'
|
|
226
|
+
'status',
|
|
227
|
+
'comment',
|
|
228
|
+
'threads',
|
|
229
|
+
'reply-to',
|
|
230
|
+
'edit',
|
|
231
|
+
'resolve',
|
|
232
|
+
'close',
|
|
233
|
+
'draft',
|
|
234
|
+
'as-user',
|
|
235
|
+
'head',
|
|
236
|
+
'base',
|
|
237
|
+
'title',
|
|
238
|
+
'body',
|
|
239
|
+
'body-file',
|
|
240
|
+
'file',
|
|
241
|
+
'line',
|
|
242
|
+
'side',
|
|
180
243
|
];
|
|
181
|
-
if (conflicts.some(
|
|
244
|
+
if (conflicts.some(name => args.has(name) || args.value(name) !== undefined) ||
|
|
245
|
+
(action !== 'update' && action !== 'open')) {
|
|
182
246
|
fail('--id only goes with --number and --jq');
|
|
183
247
|
}
|
|
184
248
|
action = 'review';
|
|
185
249
|
}
|
|
186
250
|
const accounts = args.values('as-user');
|
|
187
251
|
const asUser = args.has('as-user');
|
|
188
|
-
if (accounts.length > 1)
|
|
252
|
+
if (accounts.length > 1) {
|
|
189
253
|
fail('--as-user may only be given once');
|
|
190
|
-
|
|
254
|
+
}
|
|
255
|
+
if (asUser && accounts.length > 0) {
|
|
191
256
|
fail('--as-user cannot be both bare and given a login');
|
|
257
|
+
}
|
|
192
258
|
const account = accounts[0];
|
|
193
259
|
if (account !== undefined &&
|
|
194
260
|
action !== 'open' &&
|
|
@@ -198,7 +264,8 @@ export async function runPr(argv) {
|
|
|
198
264
|
fail('the flag-only gcb pr form only opens, replies or reviews through the host broker; use gcb gh pr ... for ' +
|
|
199
265
|
JSON.stringify(action));
|
|
200
266
|
}
|
|
201
|
-
if (asUser &&
|
|
267
|
+
if (asUser &&
|
|
268
|
+
!['open', 'resolve', 'reply', 'edit', 'comment', 'submit-review', 'update'].includes(action)) {
|
|
202
269
|
fail('the flag-only gcb pr form only opens, replies, resolves, edits or comments on a pull request, so it does not go with ' +
|
|
203
270
|
JSON.stringify(action));
|
|
204
271
|
}
|
|
@@ -213,8 +280,9 @@ export async function runPr(argv) {
|
|
|
213
280
|
// rather than part of the value: sending `owner:branch` as a base names a branch that cannot exist.
|
|
214
281
|
const baseBranch = () => {
|
|
215
282
|
const raw = args.value('base');
|
|
216
|
-
if (raw === undefined)
|
|
283
|
+
if (raw === undefined) {
|
|
217
284
|
return undefined;
|
|
285
|
+
}
|
|
218
286
|
try {
|
|
219
287
|
return baseBranchFor(raw, repo, process.cwd());
|
|
220
288
|
}
|
|
@@ -223,8 +291,9 @@ export async function runPr(argv) {
|
|
|
223
291
|
}
|
|
224
292
|
};
|
|
225
293
|
const qualified = (value) => {
|
|
226
|
-
if (value === undefined)
|
|
294
|
+
if (value === undefined) {
|
|
227
295
|
return undefined;
|
|
296
|
+
}
|
|
228
297
|
try {
|
|
229
298
|
return qualifiedBranch(value, process.cwd());
|
|
230
299
|
}
|
|
@@ -236,10 +305,12 @@ export async function runPr(argv) {
|
|
|
236
305
|
const base = baseBranch();
|
|
237
306
|
const title = args.value('title');
|
|
238
307
|
if (action === 'open') {
|
|
239
|
-
if (!head)
|
|
308
|
+
if (!head) {
|
|
240
309
|
fail('--head is required to open a pull request');
|
|
241
|
-
|
|
310
|
+
}
|
|
311
|
+
if (!title) {
|
|
242
312
|
fail('--title is required to open a pull request');
|
|
313
|
+
}
|
|
243
314
|
}
|
|
244
315
|
else if (action !== 'resolve' && action !== 'edit' && number === undefined) {
|
|
245
316
|
const verb = action === 'status' ? 'inspect' : action === 'submit-review' ? 'review' : action;
|
|
@@ -264,8 +335,9 @@ export async function runPr(argv) {
|
|
|
264
335
|
fail('an anchored comment needs both --file and --line, or neither');
|
|
265
336
|
}
|
|
266
337
|
if (filePath !== undefined) {
|
|
267
|
-
if (action !== 'comment')
|
|
338
|
+
if (action !== 'comment') {
|
|
268
339
|
fail('--file and --line anchor a comment, so they only go with --comment');
|
|
340
|
+
}
|
|
269
341
|
if (!Number.isInteger(Number(lineArg)) || Number(lineArg) <= 0) {
|
|
270
342
|
fail(`--line must be a positive integer, got ${JSON.stringify(lineArg)}`);
|
|
271
343
|
}
|
|
@@ -274,11 +346,13 @@ export async function runPr(argv) {
|
|
|
274
346
|
}
|
|
275
347
|
}
|
|
276
348
|
const replyTo = args.value('reply-to');
|
|
277
|
-
if (action === 'reply' &&
|
|
349
|
+
if (action === 'reply' &&
|
|
350
|
+
(replyTo === undefined || !Number.isInteger(Number(replyTo)) || Number(replyTo) <= 0)) {
|
|
278
351
|
fail(`--reply-to needs the id of the comment being answered, got ${JSON.stringify(replyTo)}`);
|
|
279
352
|
}
|
|
280
353
|
const editId = args.value('edit');
|
|
281
|
-
if (action === 'edit' &&
|
|
354
|
+
if (action === 'edit' &&
|
|
355
|
+
(editId === undefined || !Number.isInteger(Number(editId)) || Number(editId) <= 0)) {
|
|
282
356
|
fail(`--edit needs the id of the review comment being changed, got ${JSON.stringify(editId)}`);
|
|
283
357
|
}
|
|
284
358
|
const reviewId = args.value('id');
|
|
@@ -305,20 +379,34 @@ export async function runPr(argv) {
|
|
|
305
379
|
if ((action === 'comment' || action === 'reply' || action === 'edit') && !hasBody) {
|
|
306
380
|
fail('a comment has to say something: pass --body or --body-file');
|
|
307
381
|
}
|
|
308
|
-
if ((action === 'comment' || action === 'reply' || action === 'edit') &&
|
|
382
|
+
if ((action === 'comment' || action === 'reply' || action === 'edit') &&
|
|
383
|
+
readBody()?.trim() === '') {
|
|
309
384
|
fail('a comment has to say something: pass --body or --body-file');
|
|
310
385
|
}
|
|
311
386
|
if (action === 'review') {
|
|
312
|
-
const ghArgs = [
|
|
387
|
+
const ghArgs = [
|
|
388
|
+
'pr',
|
|
389
|
+
'review-by-id',
|
|
390
|
+
String(number),
|
|
391
|
+
reviewId,
|
|
392
|
+
'--repo',
|
|
393
|
+
repo,
|
|
394
|
+
'--host',
|
|
395
|
+
host,
|
|
396
|
+
];
|
|
313
397
|
const socketArg = args.value('socket');
|
|
314
|
-
if (socketArg !== undefined)
|
|
398
|
+
if (socketArg !== undefined) {
|
|
315
399
|
ghArgs.push('--socket', socketArg);
|
|
316
|
-
|
|
400
|
+
}
|
|
401
|
+
if (args.has('no-proxy')) {
|
|
317
402
|
ghArgs.push('--no-proxy');
|
|
318
|
-
|
|
403
|
+
}
|
|
404
|
+
else if (args.value('proxy') !== undefined) {
|
|
319
405
|
ghArgs.push('--proxy', args.value('proxy'));
|
|
320
|
-
|
|
406
|
+
}
|
|
407
|
+
if (jq !== undefined) {
|
|
321
408
|
ghArgs.push('--jq', jq);
|
|
409
|
+
}
|
|
322
410
|
return runGh(ghArgs, { unreachableExitCode: 3 });
|
|
323
411
|
}
|
|
324
412
|
if (action === 'update') {
|
|
@@ -336,26 +424,46 @@ export async function runPr(argv) {
|
|
|
336
424
|
proxy,
|
|
337
425
|
session: 'pr',
|
|
338
426
|
pid: process.pid,
|
|
339
|
-
},
|
|
427
|
+
}, answer => `edited #${answer.number ?? '?'} as ${account}${answer.url === undefined ? '' : `: ${answer.url}`}`);
|
|
340
428
|
}
|
|
341
429
|
const ghArgs = ['pr', 'edit', String(number), '--repo', repo, '--host', host];
|
|
342
|
-
if (title !== undefined)
|
|
430
|
+
if (title !== undefined) {
|
|
343
431
|
ghArgs.push(`--title=${title}`);
|
|
344
|
-
|
|
432
|
+
}
|
|
433
|
+
if (body !== undefined) {
|
|
345
434
|
ghArgs.push(`--body=${body}`);
|
|
346
|
-
|
|
435
|
+
}
|
|
436
|
+
if (base !== undefined) {
|
|
347
437
|
ghArgs.push(`--base=${base}`);
|
|
438
|
+
}
|
|
348
439
|
const socketArg = args.value('socket');
|
|
349
|
-
if (socketArg !== undefined)
|
|
440
|
+
if (socketArg !== undefined) {
|
|
350
441
|
ghArgs.push('--socket', socketArg);
|
|
351
|
-
|
|
442
|
+
}
|
|
443
|
+
if (args.has('no-proxy')) {
|
|
352
444
|
ghArgs.push('--no-proxy');
|
|
353
|
-
|
|
445
|
+
}
|
|
446
|
+
else if (args.value('proxy') !== undefined) {
|
|
354
447
|
ghArgs.push('--proxy', args.value('proxy'));
|
|
448
|
+
}
|
|
355
449
|
return runGh(ghArgs, { unreachableExitCode: 3, identity: asUser ? 'user' : 'app' });
|
|
356
450
|
}
|
|
357
451
|
if (action === 'submit-review') {
|
|
358
|
-
if ([
|
|
452
|
+
if ([
|
|
453
|
+
'threads',
|
|
454
|
+
'status',
|
|
455
|
+
'reply-to',
|
|
456
|
+
'edit',
|
|
457
|
+
'resolve',
|
|
458
|
+
'close',
|
|
459
|
+
'file',
|
|
460
|
+
'line',
|
|
461
|
+
'side',
|
|
462
|
+
'draft',
|
|
463
|
+
'head',
|
|
464
|
+
'base',
|
|
465
|
+
'title',
|
|
466
|
+
].some(name => args.has(name) || args.value(name) !== undefined)) {
|
|
359
467
|
fail('--approve/--request-changes/--review-comment cannot be combined with another action');
|
|
360
468
|
}
|
|
361
469
|
const events = [
|
|
@@ -363,8 +471,9 @@ export async function runPr(argv) {
|
|
|
363
471
|
args.has('request-changes') ? 'request-changes' : undefined,
|
|
364
472
|
args.has('review-comment') ? 'comment' : undefined,
|
|
365
473
|
].filter((event) => event !== undefined);
|
|
366
|
-
if (events.length !== 1)
|
|
474
|
+
if (events.length !== 1) {
|
|
367
475
|
fail('choose exactly one of --approve, --request-changes or --review-comment');
|
|
476
|
+
}
|
|
368
477
|
const event = events[0];
|
|
369
478
|
if (event !== 'approve' && !hasBody) {
|
|
370
479
|
fail(`--${event === 'comment' ? 'review-comment' : 'request-changes'} needs --body or --body-file`);
|
|
@@ -385,27 +494,34 @@ export async function runPr(argv) {
|
|
|
385
494
|
proxy,
|
|
386
495
|
session: 'pr',
|
|
387
496
|
pid: process.pid,
|
|
388
|
-
},
|
|
497
|
+
}, answer => `submitted ${event} review on #${answer.number ?? '?'} as ${account}${answer.url === undefined ? '' : `: ${answer.url}`}`);
|
|
389
498
|
}
|
|
390
499
|
const ghArgs = ['pr', 'review', String(number), '--repo', repo, '--host', host];
|
|
391
|
-
if (event === 'approve')
|
|
500
|
+
if (event === 'approve') {
|
|
392
501
|
ghArgs.push('--approve');
|
|
393
|
-
|
|
502
|
+
}
|
|
503
|
+
else {
|
|
394
504
|
ghArgs.push(event === 'request-changes' ? '--request-changes' : '--comment');
|
|
395
|
-
|
|
505
|
+
}
|
|
506
|
+
if (body !== undefined) {
|
|
396
507
|
ghArgs.push(`--body=${body}`);
|
|
508
|
+
}
|
|
397
509
|
const socketArg = args.value('socket');
|
|
398
|
-
if (socketArg !== undefined)
|
|
510
|
+
if (socketArg !== undefined) {
|
|
399
511
|
ghArgs.push('--socket', socketArg);
|
|
400
|
-
|
|
512
|
+
}
|
|
513
|
+
if (args.has('no-proxy')) {
|
|
401
514
|
ghArgs.push('--no-proxy');
|
|
402
|
-
|
|
515
|
+
}
|
|
516
|
+
else if (args.value('proxy') !== undefined) {
|
|
403
517
|
ghArgs.push('--proxy', args.value('proxy'));
|
|
518
|
+
}
|
|
404
519
|
return runGh(ghArgs, { unreachableExitCode: 3, identity: asUser ? 'user' : 'app' });
|
|
405
520
|
}
|
|
406
521
|
if (account !== undefined && action === 'reply') {
|
|
407
|
-
if (number === undefined || replyTo === undefined)
|
|
522
|
+
if (number === undefined || replyTo === undefined) {
|
|
408
523
|
fail('--as-user <login> needs --number and --reply-to');
|
|
524
|
+
}
|
|
409
525
|
const body = readBody();
|
|
410
526
|
return submitToHostBroker({
|
|
411
527
|
kind: 'reply',
|
|
@@ -418,11 +534,12 @@ export async function runPr(argv) {
|
|
|
418
534
|
proxy,
|
|
419
535
|
session: 'pr',
|
|
420
536
|
pid: process.pid,
|
|
421
|
-
},
|
|
537
|
+
}, answer => `replied on #${answer.number ?? '?'} as ${account}: ${answer.url ?? '(no url)'}`);
|
|
422
538
|
}
|
|
423
539
|
if (account !== undefined) {
|
|
424
|
-
if (head === undefined || title === undefined)
|
|
540
|
+
if (head === undefined || title === undefined) {
|
|
425
541
|
fail('--as-user needs --head and --title');
|
|
542
|
+
}
|
|
426
543
|
const body = hasBody ? readBody() : undefined;
|
|
427
544
|
if (args.value('repo') !== undefined && host.toLowerCase() !== 'github.com') {
|
|
428
545
|
fail('--as-user <login> with --repo only targets github.com; --host is not supported for create');
|
|
@@ -438,7 +555,7 @@ export async function runPr(argv) {
|
|
|
438
555
|
account,
|
|
439
556
|
session: 'pr',
|
|
440
557
|
pid: process.pid,
|
|
441
|
-
},
|
|
558
|
+
}, answer => `opened #${answer.number ?? '?'} (as ${account}, through the host broker): ${answer.url ?? '(no url)'}`);
|
|
442
559
|
}
|
|
443
560
|
if (socketPath === undefined) {
|
|
444
561
|
fail('no broker socket: pass --socket, set GIT_BROKER_SOCKET, or run `gcb setup`');
|