gcb-client 0.0.0 → 0.0.2
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 +24 -0
- package/bin/gcb.js +12 -0
- package/lib/commands/gh.d.ts +13 -0
- package/lib/commands/gh.d.ts.map +1 -0
- package/lib/commands/gh.js +261 -0
- package/lib/commands/gh.js.map +1 -0
- package/lib/commands/logs.d.ts +10 -0
- package/lib/commands/logs.d.ts.map +1 -0
- package/lib/commands/logs.js +97 -0
- package/lib/commands/logs.js.map +1 -0
- package/lib/commands/pr.d.ts +10 -0
- package/lib/commands/pr.d.ts.map +1 -0
- package/lib/commands/pr.js +402 -0
- package/lib/commands/pr.js.map +1 -0
- package/lib/commands/probe.d.ts +10 -0
- package/lib/commands/probe.d.ts.map +1 -0
- package/lib/commands/probe.js +83 -0
- package/lib/commands/probe.js.map +1 -0
- package/lib/commands/remotes.d.ts +56 -0
- package/lib/commands/remotes.d.ts.map +1 -0
- package/lib/commands/remotes.js +157 -0
- package/lib/commands/remotes.js.map +1 -0
- package/lib/commands/setup.d.ts +58 -0
- package/lib/commands/setup.d.ts.map +1 -0
- package/lib/commands/setup.js +178 -0
- package/lib/commands/setup.js.map +1 -0
- package/lib/helper.d.ts +77 -0
- package/lib/helper.d.ts.map +1 -0
- package/lib/helper.js +290 -0
- package/lib/helper.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +86 -0
- package/lib/index.js.map +1 -0
- package/package.json +33 -2
- package/README.md +0 -1
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `pr` — open, update or inspect one pull request through the broker.
|
|
3
|
+
*
|
|
4
|
+
* `pr <subcommand>` runs as the catalogued gh action when the catalog has one (`pr:view`,
|
|
5
|
+
* `pr:close`, …); this file is the flag-only lifecycle for the actions gh cannot express.
|
|
6
|
+
*
|
|
7
|
+
* The credential never leaves the broker. The broker mints a token narrowed to `pull_requests: write`
|
|
8
|
+
* plus read access to the branches it names, performs the action itself, and answers with the number,
|
|
9
|
+
* the URL and the state: the agent gets the lifecycle of a pull request without ever holding
|
|
10
|
+
* something that could push to it.
|
|
11
|
+
*
|
|
12
|
+
* Exit codes: 0 done, 1 refused, 3 broker unreachable.
|
|
13
|
+
*/
|
|
14
|
+
import { readFileSync } from 'node:fs';
|
|
15
|
+
import { ANSWER_TIMEOUT_MS, channelDir, findGitDir, readOpener, removeResult, waitForResult, writeRequest, } from 'gcb-core';
|
|
16
|
+
import { requestOverSocket, resolveSocketPath } from '../helper.js';
|
|
17
|
+
import { baseBranchFor, qualifiedBranch, remoteRepo } from './remotes.js';
|
|
18
|
+
import { runGh } from './gh.js';
|
|
19
|
+
import { fail, parseArgs, say } from 'gcb-core';
|
|
20
|
+
/** Every flag the flag-only lifecycle understands. */
|
|
21
|
+
const KNOWN_FLAGS = new Set([
|
|
22
|
+
'help', 'h', 'draft', 'close', 'comment', 'file', 'line', 'side', 'threads',
|
|
23
|
+
'reply-to', 'edit', 'resolve', 'id', 'jq', 'proxy', 'no-proxy', 'socket', 'host', 'repo',
|
|
24
|
+
'head', 'base', 'title', 'body', 'body-file', 'number', 'via-host', 'status',
|
|
25
|
+
]);
|
|
26
|
+
/** Longer than a credential request: a token is minted, then the action is performed. */
|
|
27
|
+
const PR_TIMEOUT_MS = 60_000;
|
|
28
|
+
/** Usage text for `pr`. */
|
|
29
|
+
export const PR_USAGE = `Usage: gcb pr [options]
|
|
30
|
+
|
|
31
|
+
Open, update or inspect a pull request through the broker, without the credential
|
|
32
|
+
ever reaching this side.
|
|
33
|
+
|
|
34
|
+
A subcommand the gh action catalog has (pr view, pr close, …) runs as that action instead;
|
|
35
|
+
gcb gh --help lists them. The flags below are the flag-only lifecycle gh cannot express.
|
|
36
|
+
|
|
37
|
+
Opening (the default)
|
|
38
|
+
--head <branch> The branch holding the change [required]
|
|
39
|
+
May be <remote>:<branch>, e.g. origin:feat/x, to name a fork
|
|
40
|
+
--base <branch> The branch to merge into (default: main)
|
|
41
|
+
A <remote>:<branch> here names the same repository as --repo
|
|
42
|
+
--title <text> The title [required]
|
|
43
|
+
--body <text> The body, inline
|
|
44
|
+
--body-file <path> The body, read from a file — a pull request body is usually long
|
|
45
|
+
--draft Open it as a draft
|
|
46
|
+
--via-host Ask a host-side opener to create it, as you, instead of as the app
|
|
47
|
+
(run 'gcb host-opener' on the host to provide one)
|
|
48
|
+
|
|
49
|
+
Acting on one
|
|
50
|
+
--number <n> The pull request number [required]
|
|
51
|
+
--proxy <url> Use this proxy for this request
|
|
52
|
+
--no-proxy Reach GitHub directly for this request
|
|
53
|
+
--status Report its state, mergeability and the runs for its commit
|
|
54
|
+
--comment Post an anchored review comment (also needs --file and --line);
|
|
55
|
+
for a plain comment use: gcb gh pr comment <number> --body ...
|
|
56
|
+
--file <path> Anchor that comment to a line of this file, repository-relative
|
|
57
|
+
--line <n> The line to anchor to, in the new file unless --side says otherwise
|
|
58
|
+
--side <left|right> Which side of the diff --line counts on (default: right)
|
|
59
|
+
--threads List its review threads: their ids, whether they are resolved, and the comments
|
|
60
|
+
--reply-to <id> Reply inside the thread that comment id belongs to, with --body/--body-file
|
|
61
|
+
--edit <id> Replace the body of that review comment, with --body/--body-file
|
|
62
|
+
(an id --threads prints; no --number is needed)
|
|
63
|
+
--resolve <thread> Mark that review thread resolved (the id --threads prints)
|
|
64
|
+
--id <review-id> Show one existing review (with --number)
|
|
65
|
+
--jq <expr> Filter that review's JSON (with --id)
|
|
66
|
+
With --number and none of the above, the title, body or base is updated.
|
|
67
|
+
|
|
68
|
+
Common
|
|
69
|
+
--socket <path> Broker socket (default: $GIT_BROKER_SOCKET or the socket file)
|
|
70
|
+
--host <host> Host as configured, e.g. github.com (default: github.com)
|
|
71
|
+
--repo <owner/name> Repository the pull request belongs to (default: origin remote)
|
|
72
|
+
-h, --help Show this help
|
|
73
|
+
`;
|
|
74
|
+
/** A positive decimal identifier that survives Number() without losing precision. */
|
|
75
|
+
const isPositiveSafeInteger = (value) => value !== undefined && /^[1-9][0-9]*$/.test(value) && Number.isSafeInteger(Number(value));
|
|
76
|
+
/**
|
|
77
|
+
* Read the action out of the flags.
|
|
78
|
+
*
|
|
79
|
+
* @param args - the parsed arguments.
|
|
80
|
+
* @returns the selected action; `--id` is applied by the caller as `review`.
|
|
81
|
+
*/
|
|
82
|
+
function actionOf(args) {
|
|
83
|
+
// `--resolve`, `--reply-to` and `--edit` take a value, and a bare one is parsed as a boolean flag with
|
|
84
|
+
// no value at all. Selecting the action from the flag's *presence* is what turns that into the refusal
|
|
85
|
+
// below — reading only `value` let a bare `--edit` fall through to `update`, which patched the pull
|
|
86
|
+
// request itself with the body meant for the comment.
|
|
87
|
+
const present = (name) => args.has(name) || args.value(name) !== undefined;
|
|
88
|
+
if (present('resolve'))
|
|
89
|
+
return 'resolve';
|
|
90
|
+
if (present('reply-to'))
|
|
91
|
+
return 'reply';
|
|
92
|
+
if (present('edit'))
|
|
93
|
+
return 'edit';
|
|
94
|
+
if (args.has('threads'))
|
|
95
|
+
return 'threads';
|
|
96
|
+
if (args.has('comment'))
|
|
97
|
+
return 'comment';
|
|
98
|
+
if (args.has('status'))
|
|
99
|
+
return 'status';
|
|
100
|
+
if (args.value('number') !== undefined)
|
|
101
|
+
return 'update';
|
|
102
|
+
return 'open';
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Run the `pr` command.
|
|
106
|
+
*
|
|
107
|
+
* @param argv - arguments after the command name.
|
|
108
|
+
* @returns the process exit code: 0 done, 1 refused, 3 unreachable.
|
|
109
|
+
*/
|
|
110
|
+
export async function runPr(argv) {
|
|
111
|
+
const args = parseArgs(argv, {
|
|
112
|
+
booleans: ['help', 'draft', 'status', 'comment', 'threads', 'via-host', 'no-proxy'],
|
|
113
|
+
});
|
|
114
|
+
if (args.has('help') || args.has('h')) {
|
|
115
|
+
say(PR_USAGE);
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
// Unknown options are refused rather than ignored: a typo must not silently fall through to an update.
|
|
119
|
+
for (const name of args.names) {
|
|
120
|
+
if (!KNOWN_FLAGS.has(name))
|
|
121
|
+
fail('unknown option --' + name + ' for gcb pr');
|
|
122
|
+
}
|
|
123
|
+
if (args.positionals.length > 0)
|
|
124
|
+
fail('unexpected argument ' + JSON.stringify(args.positionals[0]) + ' for gcb pr');
|
|
125
|
+
// Before --repo: the point of the message is to name the command that does it now.
|
|
126
|
+
if (args.has('close') || args.value('close') !== undefined) {
|
|
127
|
+
fail('--close moved to: gcb gh pr close <number> --repo owner/name');
|
|
128
|
+
}
|
|
129
|
+
// Before --repo too: a bare `gcb pr --comment` should hear what the flag needs, not that --repo
|
|
130
|
+
// is missing. An anchored comment (--file and --line) is still this command's to post.
|
|
131
|
+
if (args.has('comment') && args.value('file') === undefined && args.value('line') === undefined) {
|
|
132
|
+
fail('--comment only posts an anchored review comment; pass --file and --line');
|
|
133
|
+
}
|
|
134
|
+
if (args.has('no-proxy') && args.value('proxy') !== undefined) {
|
|
135
|
+
fail('--proxy and --no-proxy are mutually exclusive');
|
|
136
|
+
}
|
|
137
|
+
if (args.has('proxy') && args.value('proxy') === undefined)
|
|
138
|
+
fail('--proxy needs a value');
|
|
139
|
+
const proxy = args.has('no-proxy') ? null : args.value('proxy');
|
|
140
|
+
const socketPath = resolveSocketPath(args.value('socket'), process.env);
|
|
141
|
+
const looksLikeOption = (value) => value.startsWith('--') || /^-(?=[A-Za-z])/.test(value);
|
|
142
|
+
const invalidValue = (name) => args.has(name) || args.values(name).some((value) => value.trim() === '' || looksLikeOption(value));
|
|
143
|
+
const hasValue = (name) => args.has(name) || args.values(name).length > 0;
|
|
144
|
+
const hostArg = args.value('host');
|
|
145
|
+
if (hasValue('host') && invalidValue('host'))
|
|
146
|
+
fail('--host needs a value (e.g. github.com)');
|
|
147
|
+
const host = hostArg ?? 'github.com';
|
|
148
|
+
const repoArg = args.value('repo');
|
|
149
|
+
if (hasValue('repo') && invalidValue('repo'))
|
|
150
|
+
fail('--repo needs a value (e.g. owner/name)');
|
|
151
|
+
let repo = repoArg;
|
|
152
|
+
if (repo === undefined) {
|
|
153
|
+
const found = remoteRepo('origin', process.cwd());
|
|
154
|
+
if (found === undefined)
|
|
155
|
+
fail('--repo is required when the checkout has no usable origin remote');
|
|
156
|
+
if (found.host !== host.toLowerCase()) {
|
|
157
|
+
fail(`the checkout's remote is on ${found.host}, but --host is ${host}; pass --repo or --host`);
|
|
158
|
+
}
|
|
159
|
+
repo = `${found.owner}/${found.repo}`;
|
|
160
|
+
}
|
|
161
|
+
if (repo.trim() === '')
|
|
162
|
+
fail('--repo needs a value (e.g. owner/name)');
|
|
163
|
+
let action = actionOf(args);
|
|
164
|
+
const hasReviewId = args.has('id') || args.value('id') !== undefined;
|
|
165
|
+
if (hasReviewId) {
|
|
166
|
+
const conflicts = [
|
|
167
|
+
'status', 'comment', 'threads', 'reply-to', 'edit', 'resolve', 'close', 'draft', 'via-host',
|
|
168
|
+
'head', 'base', 'title', 'body', 'body-file', 'file', 'line', 'side',
|
|
169
|
+
];
|
|
170
|
+
if (conflicts.some((name) => args.has(name) || args.value(name) !== undefined) || (action !== 'update' && action !== 'open')) {
|
|
171
|
+
fail('--id only goes with --number and --jq');
|
|
172
|
+
}
|
|
173
|
+
action = 'review';
|
|
174
|
+
}
|
|
175
|
+
if (args.has('via-host') && action !== 'open') {
|
|
176
|
+
fail('--via-host only creates a pull request, so it does not go with ' + JSON.stringify(action));
|
|
177
|
+
}
|
|
178
|
+
const viaHost = action === 'open' && args.has('via-host');
|
|
179
|
+
const number = args.value('number');
|
|
180
|
+
// `--head origin:feat/x` and `--base upstream:main` name a configured remote instead of a repository
|
|
181
|
+
// typed by hand: it is the name this checkout already pushes to, and a typo lists the ones that exist.
|
|
182
|
+
// The base is a branch of the repository --repo names, so the owner a remote resolves to is a check
|
|
183
|
+
// rather than part of the value: sending `owner:branch` as a base names a branch that cannot exist.
|
|
184
|
+
const baseBranch = () => {
|
|
185
|
+
const raw = args.value('base');
|
|
186
|
+
if (raw === undefined)
|
|
187
|
+
return undefined;
|
|
188
|
+
try {
|
|
189
|
+
return baseBranchFor(raw, repo, process.cwd());
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
fail(error.message);
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
const qualified = (value) => {
|
|
196
|
+
if (value === undefined)
|
|
197
|
+
return undefined;
|
|
198
|
+
try {
|
|
199
|
+
return qualifiedBranch(value, process.cwd());
|
|
200
|
+
}
|
|
201
|
+
catch (error) {
|
|
202
|
+
fail(error.message);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
const head = qualified(args.value('head'));
|
|
206
|
+
const base = baseBranch();
|
|
207
|
+
const title = args.value('title');
|
|
208
|
+
const bodyFile = args.value('body-file');
|
|
209
|
+
let body = args.value('body');
|
|
210
|
+
if (bodyFile !== undefined) {
|
|
211
|
+
try {
|
|
212
|
+
body = readFileSync(bodyFile, 'utf8');
|
|
213
|
+
}
|
|
214
|
+
catch (error) {
|
|
215
|
+
fail(`cannot read ${bodyFile}: ${error.message}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (action === 'open') {
|
|
219
|
+
if (!head)
|
|
220
|
+
fail('--head is required to open a pull request');
|
|
221
|
+
if (!title)
|
|
222
|
+
fail('--title is required to open a pull request');
|
|
223
|
+
}
|
|
224
|
+
else if (action !== 'resolve' && action !== 'edit' && number === undefined) {
|
|
225
|
+
const verb = action === 'status' ? 'inspect' : action;
|
|
226
|
+
fail(`--number is required to ${verb} a pull request`);
|
|
227
|
+
}
|
|
228
|
+
// `--resolve` and `--edit` name their target by id and need no pull request number, but one given
|
|
229
|
+
// anyway still has to be a number.
|
|
230
|
+
if (number !== undefined && !isPositiveSafeInteger(number)) {
|
|
231
|
+
fail(`--number must be a positive integer, got ${JSON.stringify(number)}`);
|
|
232
|
+
}
|
|
233
|
+
const jq = args.value('jq');
|
|
234
|
+
if ((args.has('jq') && jq === undefined) || (jq !== undefined && jq.trim() === '')) {
|
|
235
|
+
fail('--jq needs an expression');
|
|
236
|
+
}
|
|
237
|
+
if (jq !== undefined && action !== 'review') {
|
|
238
|
+
fail('--jq only goes with --id');
|
|
239
|
+
}
|
|
240
|
+
if (action === 'update' && title === undefined && body === undefined && base === undefined) {
|
|
241
|
+
fail('an update has to change something: pass --title, --body/--body-file or --base');
|
|
242
|
+
}
|
|
243
|
+
if ((action === 'comment' || action === 'reply' || action === 'edit') && (body === undefined || body.trim() === '')) {
|
|
244
|
+
fail('a comment has to say something: pass --body or --body-file');
|
|
245
|
+
}
|
|
246
|
+
const filePath = args.value('file');
|
|
247
|
+
const lineArg = args.value('line');
|
|
248
|
+
const side = (args.value('side') ?? 'right').toLowerCase();
|
|
249
|
+
if ((filePath === undefined) !== (lineArg === undefined)) {
|
|
250
|
+
fail('an anchored comment needs both --file and --line, or neither');
|
|
251
|
+
}
|
|
252
|
+
if (filePath !== undefined) {
|
|
253
|
+
if (action !== 'comment')
|
|
254
|
+
fail('--file and --line anchor a comment, so they only go with --comment');
|
|
255
|
+
if (!Number.isInteger(Number(lineArg)) || Number(lineArg) <= 0) {
|
|
256
|
+
fail(`--line must be a positive integer, got ${JSON.stringify(lineArg)}`);
|
|
257
|
+
}
|
|
258
|
+
if (side !== 'left' && side !== 'right') {
|
|
259
|
+
fail(`--side must be left or right, got ${JSON.stringify(args.value('side'))}`);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
const replyTo = args.value('reply-to');
|
|
263
|
+
if (action === 'reply' && (replyTo === undefined || !Number.isInteger(Number(replyTo)) || Number(replyTo) <= 0)) {
|
|
264
|
+
fail(`--reply-to needs the id of the comment being answered, got ${JSON.stringify(replyTo)}`);
|
|
265
|
+
}
|
|
266
|
+
const editId = args.value('edit');
|
|
267
|
+
if (action === 'edit' && (editId === undefined || !Number.isInteger(Number(editId)) || Number(editId) <= 0)) {
|
|
268
|
+
fail(`--edit needs the id of the review comment being changed, got ${JSON.stringify(editId)}`);
|
|
269
|
+
}
|
|
270
|
+
const reviewId = args.value('id');
|
|
271
|
+
if (action === 'review' && !isPositiveSafeInteger(reviewId)) {
|
|
272
|
+
fail(`--id needs a positive review id, got ${JSON.stringify(reviewId)}`);
|
|
273
|
+
}
|
|
274
|
+
const resolveId = args.value('resolve');
|
|
275
|
+
if (action === 'resolve' && (resolveId === undefined || resolveId.trim() === '')) {
|
|
276
|
+
fail(`--resolve needs the id of the thread being resolved, got ${JSON.stringify(resolveId)}`);
|
|
277
|
+
}
|
|
278
|
+
if (action === 'review') {
|
|
279
|
+
const ghArgs = ['pr', 'review-by-id', String(number), reviewId, '--repo', repo, '--host', host];
|
|
280
|
+
const socketArg = args.value('socket');
|
|
281
|
+
if (socketArg !== undefined)
|
|
282
|
+
ghArgs.push('--socket', socketArg);
|
|
283
|
+
if (args.has('no-proxy'))
|
|
284
|
+
ghArgs.push('--no-proxy');
|
|
285
|
+
else if (args.value('proxy') !== undefined)
|
|
286
|
+
ghArgs.push('--proxy', args.value('proxy'));
|
|
287
|
+
if (jq !== undefined)
|
|
288
|
+
ghArgs.push('--jq', jq);
|
|
289
|
+
return runGh(ghArgs, { unreachableExitCode: 3 });
|
|
290
|
+
}
|
|
291
|
+
if (action === 'update') {
|
|
292
|
+
const ghArgs = ['pr', 'edit', String(number), '--repo', repo, '--host', host];
|
|
293
|
+
if (title !== undefined)
|
|
294
|
+
ghArgs.push(`--title=${title}`);
|
|
295
|
+
if (body !== undefined)
|
|
296
|
+
ghArgs.push(`--body=${body}`);
|
|
297
|
+
if (base !== undefined)
|
|
298
|
+
ghArgs.push(`--base=${base}`);
|
|
299
|
+
const socketArg = args.value('socket');
|
|
300
|
+
if (socketArg !== undefined)
|
|
301
|
+
ghArgs.push('--socket', socketArg);
|
|
302
|
+
if (args.has('no-proxy'))
|
|
303
|
+
ghArgs.push('--no-proxy');
|
|
304
|
+
else if (args.value('proxy') !== undefined)
|
|
305
|
+
ghArgs.push('--proxy', args.value('proxy'));
|
|
306
|
+
return runGh(ghArgs, { unreachableExitCode: 3 });
|
|
307
|
+
}
|
|
308
|
+
if (viaHost) {
|
|
309
|
+
if (head === undefined || title === undefined)
|
|
310
|
+
fail('--via-host needs --head and --title');
|
|
311
|
+
const gitDir = findGitDir(process.cwd());
|
|
312
|
+
if (gitDir === undefined)
|
|
313
|
+
fail('--via-host needs a git repository: run it from the checkout');
|
|
314
|
+
const dir = channelDir(gitDir);
|
|
315
|
+
if (readOpener(dir) === undefined) {
|
|
316
|
+
fail(`no host opener is watching ${dir}\n` +
|
|
317
|
+
' start one on the host: gcb host-opener --repo <that checkout>\n' +
|
|
318
|
+
' or drop --via-host to open it as the app instead');
|
|
319
|
+
}
|
|
320
|
+
// writeRequest refuses a request the opener would have to refuse: a title past its limit, a body past
|
|
321
|
+
// its limit, a head equal to its base. It throws, and a stack trace tells the caller none of that.
|
|
322
|
+
let id;
|
|
323
|
+
try {
|
|
324
|
+
id = writeRequest(dir, {
|
|
325
|
+
repo,
|
|
326
|
+
head,
|
|
327
|
+
base: base ?? 'main',
|
|
328
|
+
title,
|
|
329
|
+
body: body ?? '',
|
|
330
|
+
draft: args.has('draft'),
|
|
331
|
+
proxy,
|
|
332
|
+
session: 'pr',
|
|
333
|
+
pid: process.pid,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
fail(error.message);
|
|
338
|
+
}
|
|
339
|
+
const answer = await waitForResult(dir, id, ANSWER_TIMEOUT_MS);
|
|
340
|
+
removeResult(dir, id);
|
|
341
|
+
if (answer === undefined) {
|
|
342
|
+
fail(`the host opener did not answer ${id} within ${Math.round(ANSWER_TIMEOUT_MS / 1000)}s\n` +
|
|
343
|
+
' it may still be working: the request is not cancelled, and the opener removes it only once\n' +
|
|
344
|
+
' it has created the pull request or failed. Check the pull request list before asking again.');
|
|
345
|
+
}
|
|
346
|
+
if (answer.error !== undefined)
|
|
347
|
+
fail(`the host opener could not open it: ${answer.error}`);
|
|
348
|
+
say(`opened #${answer.number ?? '?'} (as you, through the host opener): ${answer.url ?? '(no url)'}`);
|
|
349
|
+
return 0;
|
|
350
|
+
}
|
|
351
|
+
if (socketPath === undefined) {
|
|
352
|
+
fail('no broker socket: pass --socket, set GIT_BROKER_SOCKET, or run `gcb setup`');
|
|
353
|
+
}
|
|
354
|
+
let response;
|
|
355
|
+
try {
|
|
356
|
+
response = await requestOverSocket(socketPath, {
|
|
357
|
+
v: 1,
|
|
358
|
+
op: 'pull-request',
|
|
359
|
+
host,
|
|
360
|
+
path: repo,
|
|
361
|
+
action,
|
|
362
|
+
...(number === undefined || action === 'edit' ? {} : { number: Number(number) }),
|
|
363
|
+
...(action === 'reply' ? { commentId: Number(replyTo) } : {}),
|
|
364
|
+
...(action === 'edit' ? { commentId: Number(editId) } : {}),
|
|
365
|
+
...(action === 'resolve' ? { threadId: args.value('resolve') } : {}),
|
|
366
|
+
...(head === undefined ? {} : { head }),
|
|
367
|
+
...(base === undefined ? {} : { base }),
|
|
368
|
+
...(title === undefined ? {} : { title }),
|
|
369
|
+
...(body === undefined ? {} : { body }),
|
|
370
|
+
...(filePath === undefined ? {} : { filePath, line: Number(lineArg), side }),
|
|
371
|
+
draft: args.has('draft'),
|
|
372
|
+
session: 'pr',
|
|
373
|
+
pid: process.pid,
|
|
374
|
+
proxy,
|
|
375
|
+
}, PR_TIMEOUT_MS);
|
|
376
|
+
}
|
|
377
|
+
catch (error) {
|
|
378
|
+
process.stderr.write(`unreachable: ${error.message}\n`);
|
|
379
|
+
return 3;
|
|
380
|
+
}
|
|
381
|
+
if (!response.ok) {
|
|
382
|
+
process.stderr.write(`refused [${response.code ?? 'unknown'}]: ${response.reason ?? 'no reason given'}\n`);
|
|
383
|
+
return 1;
|
|
384
|
+
}
|
|
385
|
+
if (action === 'status' || action === 'threads' || action === 'resolve') {
|
|
386
|
+
say(response.prStatus ?? 'no report');
|
|
387
|
+
return 0;
|
|
388
|
+
}
|
|
389
|
+
const done = action === 'open'
|
|
390
|
+
? 'opened'
|
|
391
|
+
: action === 'comment'
|
|
392
|
+
? 'commented on'
|
|
393
|
+
: action === 'reply'
|
|
394
|
+
? 'replied in'
|
|
395
|
+
: action === 'edit'
|
|
396
|
+
? 'edited a review comment on'
|
|
397
|
+
: 'updated';
|
|
398
|
+
const state = response.prState === undefined ? '' : ` (${response.prState})`;
|
|
399
|
+
say(`${done} #${response.prNumber ?? '?'}${state}: ${response.prUrl ?? '(no url)'}`);
|
|
400
|
+
return 0;
|
|
401
|
+
}
|
|
402
|
+
//# sourceMappingURL=pr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pr.js","sourceRoot":"","sources":["../../src/commands/pr.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EACL,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEhD,sDAAsD;AACtD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS;IAC3E,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM;IACxF,MAAM,EAAE,MAAM,EAAE,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M;QACf,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,MAAM,KAAK,SAAS;YAChB,CAAC,CAAC,cAAc;YAChB,CAAC,CAAC,MAAM,KAAK,OAAO;gBAClB,CAAC,CAAC,YAAY;gBACd,CAAC,CAAC,MAAM,KAAK,MAAM;oBACjB,CAAC,CAAC,4BAA4B;oBAC9B,CAAC,CAAC,SAAS,CAAC;IAC1B,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,OAAO,GAAG,CAAC;IAC7E,GAAG,CAAC,GAAG,IAAI,KAAK,QAAQ,CAAC,QAAQ,IAAI,GAAG,GAAG,KAAK,KAAK,QAAQ,CAAC,KAAK,IAAI,UAAU,EAAE,CAAC,CAAC;IACrF,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Usage text for `probe`. */
|
|
2
|
+
export declare const PROBE_USAGE = "Usage: gcb probe [options]\n\nAsk the broker for a credential without pushing. Prints a fingerprint, never the credential.\n\n --socket <path> Broker socket (default: $GIT_BROKER_SOCKET or the socket file)\n --host <host> Host as git reports it (default: github.com)\n --repo <owner/name> Repository path [required]\n --protocol <p> https (default) or http for a host that opted in\n --proxy <url> Use this proxy for this request\n --no-proxy Reach GitHub directly for this request\n -h, --help Show this help\n";
|
|
3
|
+
/**
|
|
4
|
+
* Run the `probe` command.
|
|
5
|
+
*
|
|
6
|
+
* @param argv - arguments after the command name.
|
|
7
|
+
* @returns the process exit code: 0 allowed, 1 denied, 3 unreachable.
|
|
8
|
+
*/
|
|
9
|
+
export declare function runProbe(argv: readonly string[]): Promise<number>;
|
|
10
|
+
//# sourceMappingURL=probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../src/commands/probe.ts"],"names":[],"mappings":"AAWA,8BAA8B;AAC9B,eAAO,MAAM,WAAW,kkBAWvB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAsDvE"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `probe` — ask the broker what it would do for one repository, without pushing.
|
|
3
|
+
*
|
|
4
|
+
* Exercises the real path (JWT, installation lookup, permission pre-flight, token mint) and
|
|
5
|
+
* reports the decision with the credential reduced to a fingerprint, so the output is safe to
|
|
6
|
+
* paste anywhere. Exit codes: 0 allowed, 1 denied, 3 broker unreachable.
|
|
7
|
+
*/
|
|
8
|
+
import { tokenFingerprint } from 'gcb-core';
|
|
9
|
+
import { requestOverSocket, resolveSocketPath } from '../helper.js';
|
|
10
|
+
import { fail, parseArgs, say } from 'gcb-core';
|
|
11
|
+
/** Usage text for `probe`. */
|
|
12
|
+
export const PROBE_USAGE = `Usage: gcb probe [options]
|
|
13
|
+
|
|
14
|
+
Ask the broker for a credential without pushing. Prints a fingerprint, never the credential.
|
|
15
|
+
|
|
16
|
+
--socket <path> Broker socket (default: $GIT_BROKER_SOCKET or the socket file)
|
|
17
|
+
--host <host> Host as git reports it (default: github.com)
|
|
18
|
+
--repo <owner/name> Repository path [required]
|
|
19
|
+
--protocol <p> https (default) or http for a host that opted in
|
|
20
|
+
--proxy <url> Use this proxy for this request
|
|
21
|
+
--no-proxy Reach GitHub directly for this request
|
|
22
|
+
-h, --help Show this help
|
|
23
|
+
`;
|
|
24
|
+
/**
|
|
25
|
+
* Run the `probe` command.
|
|
26
|
+
*
|
|
27
|
+
* @param argv - arguments after the command name.
|
|
28
|
+
* @returns the process exit code: 0 allowed, 1 denied, 3 unreachable.
|
|
29
|
+
*/
|
|
30
|
+
export async function runProbe(argv) {
|
|
31
|
+
const args = parseArgs(argv, { booleans: ['help', 'no-proxy'] });
|
|
32
|
+
if (args.has('no-proxy') && args.value('proxy') !== undefined)
|
|
33
|
+
fail('--proxy and --no-proxy are mutually exclusive');
|
|
34
|
+
if (args.has('proxy') && args.value('proxy') === undefined)
|
|
35
|
+
fail('--proxy needs a value');
|
|
36
|
+
const proxy = args.has('no-proxy') ? null : args.value('proxy');
|
|
37
|
+
if (args.has('help') || args.has('h')) {
|
|
38
|
+
say(PROBE_USAGE);
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
const socketPath = resolveSocketPath(args.value('socket'), process.env);
|
|
42
|
+
const hostArg = args.value('host');
|
|
43
|
+
if (args.has('host') && hostArg === undefined)
|
|
44
|
+
fail('--host needs a value');
|
|
45
|
+
if (hostArg === '')
|
|
46
|
+
fail('--host needs a value');
|
|
47
|
+
const host = hostArg ?? 'github.com';
|
|
48
|
+
const repo = args.value('repo');
|
|
49
|
+
if (!socketPath) {
|
|
50
|
+
fail('no broker socket: pass --socket, set GIT_BROKER_SOCKET, or run `gcb setup`');
|
|
51
|
+
}
|
|
52
|
+
if (!repo)
|
|
53
|
+
fail('--repo is required (e.g. owner/name)');
|
|
54
|
+
const protocol = args.value('protocol') ?? 'https';
|
|
55
|
+
let response;
|
|
56
|
+
try {
|
|
57
|
+
response = await requestOverSocket(socketPath, {
|
|
58
|
+
v: 1,
|
|
59
|
+
op: 'credential',
|
|
60
|
+
protocol,
|
|
61
|
+
host,
|
|
62
|
+
path: repo,
|
|
63
|
+
proxy,
|
|
64
|
+
session: 'probe',
|
|
65
|
+
pid: process.pid,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
process.stderr.write(`unreachable: ${error.message}\n`);
|
|
70
|
+
return 3;
|
|
71
|
+
}
|
|
72
|
+
if (!response.ok) {
|
|
73
|
+
process.stderr.write(`denied [${response.code ?? 'unknown'}]: ${response.reason ?? 'no reason given'}\n`);
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
const password = response.password ?? '';
|
|
77
|
+
say(`allowed: ${host}/${repo} over ${protocol}`);
|
|
78
|
+
say(` username : ${response.username ?? '(none)'}`);
|
|
79
|
+
say(` expires_at : ${response.expires_at ?? '(unknown)'}`);
|
|
80
|
+
say(` credential : ${password ? `present, fingerprint ${tokenFingerprint(password)} (value not printed)` : 'MISSING'}`);
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"probe.js","sourceRoot":"","sources":["../../src/commands/probe.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEhD,8BAA8B;AAC9B,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;CAW1B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAuB;IACpD,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC;IACjE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,SAAS;QAAE,IAAI,CAAC,+CAA+C,CAAC,CAAC;IACrH,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,SAAS;QAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC1F,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAChE,I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,KAAe,CAAC,OAAO,IAAI,CAAC,CAAC;QACnE,OAAO,CAAC,CAAC;IACX,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,QAAQ,CAAC,IAAI,IAAI,SAAS,MAAM,QAAQ,CAAC,MAAM,IAAI,iBAAiB,IAAI,CAAC,CAAC;QAC1G,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,IAAI,EAAE,CAAC;IACzC,GAAG,CAAC,YAAY,IAAI,IAAI,IAAI,SAAS,QAAQ,EAAE,CAAC,CAAC;IACjD,GAAG,CAAC,qBAAqB,QAAQ,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC,CAAC;IAC1D,GAAG,CAAC,qBAAqB,QAAQ,CAAC,UAAU,IAAI,WAAW,EAAE,CAAC,CAAC;IAC/D,GAAG,CACD,qBACE,QAAQ,CAAC,CAAC,CAAC,wBAAwB,gBAAgB,CAAC,QAAQ,CAAC,sBAAsB,CAAC,CAAC,CAAC,SACxF,EAAE,CACH,CAAC;IACF,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** What a remote's URL says: the owner, repository and host key, for a GitHub-shaped URL. */
|
|
2
|
+
export interface RemoteRepo {
|
|
3
|
+
readonly owner: string;
|
|
4
|
+
readonly repo: string;
|
|
5
|
+
/** The host key: `host:port` for HTTP(S), or the host alone for SSH and git URLs. */
|
|
6
|
+
readonly host: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The remotes this checkout knows, in the order git lists them.
|
|
10
|
+
*
|
|
11
|
+
* @param cwd - the directory to ask.
|
|
12
|
+
* @returns the names, possibly empty.
|
|
13
|
+
*/
|
|
14
|
+
export declare function listRemotes(cwd: string): string[];
|
|
15
|
+
/**
|
|
16
|
+
* What repository a remote points at.
|
|
17
|
+
*
|
|
18
|
+
* HTTPS and SSH spell the same thing differently, and both end in `owner/repo`, optionally with a `.git`.
|
|
19
|
+
*
|
|
20
|
+
* @param name - the remote name.
|
|
21
|
+
* @param cwd - the directory to ask.
|
|
22
|
+
* @returns the owner, repository and host, or undefined when there is no such remote or the URL is not one.
|
|
23
|
+
*/
|
|
24
|
+
export declare function remoteRepo(name: string, cwd: string, push?: boolean): RemoteRepo | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The URL a remote points at, for saying what was wrong with it.
|
|
27
|
+
*
|
|
28
|
+
* @param name - the remote name.
|
|
29
|
+
* @param cwd - the directory to ask.
|
|
30
|
+
* @returns the URL, or undefined when there is no such remote.
|
|
31
|
+
*/
|
|
32
|
+
export declare function remoteUrl(name: string, cwd: string): string | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* Turn `remote:branch` into `owner:branch`, and leave a plain branch alone.
|
|
35
|
+
*
|
|
36
|
+
* @param value - what the operator wrote.
|
|
37
|
+
* @param cwd - the directory to resolve remotes in.
|
|
38
|
+
* @returns the value to send.
|
|
39
|
+
* @throws {Error} when the prefix is not a remote this checkout knows, naming the ones it does.
|
|
40
|
+
*/
|
|
41
|
+
export declare function qualifiedBranch(value: string, cwd: string): string;
|
|
42
|
+
/**
|
|
43
|
+
* The branch a `--base` means, given the repository the pull request lands in.
|
|
44
|
+
*
|
|
45
|
+
* `--base upstream:main` names the remote for the check and the branch for the wire: a base is a branch of
|
|
46
|
+
* `--repo`, and `owner:branch` is not a branch name anywhere. A remote pointing at a different repository
|
|
47
|
+
* is a mistake worth catching here rather than letting GitHub answer confusingly.
|
|
48
|
+
*
|
|
49
|
+
* @param raw - what the operator wrote.
|
|
50
|
+
* @param repo - the repository `--repo` names, as `owner/name`.
|
|
51
|
+
* @param cwd - the directory to resolve remotes in.
|
|
52
|
+
* @returns the branch to send.
|
|
53
|
+
* @throws {Error} when the remote points at a repository other than `repo`.
|
|
54
|
+
*/
|
|
55
|
+
export declare function baseBranchFor(raw: string, repo: string, cwd: string): string;
|
|
56
|
+
//# sourceMappingURL=remotes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remotes.d.ts","sourceRoot":"","sources":["../../src/commands/remotes.ts"],"names":[],"mappings":"AAcA,6FAA6F;AAC7F,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAsBD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAKjD;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,UAAQ,GAAG,UAAU,GAAG,SAAS,CAmC1F;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEvE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAoBlE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAe5E"}
|