diff --git a/README.md b/README.md index 3f66ec27..8e675d6a 100644 --- a/README.md +++ b/README.md @@ -117,10 +117,12 @@ Debian package is not used are recorded in ```sh gcb gh pr view 12 --repo owner/name -gcb gh pr create --repo owner/name --head feat/x --title "A title" --body "A body" +gcb gh pr create -R owner/name --head feat/x --title "A title" --body "A body" gcb gh run view 123456 --log --repo owner/name ``` +`-R` is the short form of `--repo`, as in `gh` itself. + Inside a checkout, `--repo` can be omitted only when `origin` names a usable GitHub repository whose host matches `--host`; otherwise pass `--repo`, or the matching `--host`. diff --git a/packages/client/src/commands/gh.ts b/packages/client/src/commands/gh.ts index d8ebe440..d5bc76e2 100644 --- a/packages/client/src/commands/gh.ts +++ b/packages/client/src/commands/gh.ts @@ -50,10 +50,10 @@ export const GH_USAGE = `Usage: gcb gh [options] Run a catalogued GitHub action through the broker. Common - --repo Repository the action belongs to (default: origin remote) - --host Host as configured, e.g. github.com (default: github.com) - --socket Broker socket (default: GIT_BROKER_SOCKET) - -h, --help Show this help + -R, --repo Repository the action belongs to (default: origin remote) + --host Host as configured, e.g. github.com (default: github.com) + --socket Broker socket (default: GIT_BROKER_SOCKET) + -h, --help Show this help Commands, from the action catalog ${ACTION_LINES}`; @@ -84,7 +84,7 @@ export async function runGh(argv: readonly string[]): Promise { const booleans = action.flags.filter((flag) => flag.type === 'boolean').map((flag) => flag.name); const args = parseArgs(rest, { booleans }); const host = args.value('host') ?? 'github.com'; - let repo = args.value('repo'); + let repo = args.value('repo') ?? args.value('R'); if (repo === undefined) { const found = repoFromCheckout(process.cwd()); if (found === undefined) fail('--repo is required when the checkout has no usable origin remote'); @@ -99,6 +99,7 @@ export async function runGh(argv: readonly string[]): Promise { const allowed = new Set([ ...action.flags.map((flag) => flag.name), 'repo', + 'R', 'host', 'socket', ]); diff --git a/test/unit/gh-command.test.ts b/test/unit/gh-command.test.ts index a7edf1f4..651068b7 100644 --- a/test/unit/gh-command.test.ts +++ b/test/unit/gh-command.test.ts @@ -88,7 +88,7 @@ describe('gcb gh', () => { }; const broker = await startBroker({ config, audit, providers: new Map([['github.com', provider]]) }); try { - const result = await runGhCli(['pr', 'view', '7', '--repo', 'acme/widget', '--socket', socketPath]); + const result = await runGhCli(['pr', 'view', '7', '-R', 'acme/widget', '--socket', socketPath]); assert.equal(result.status, 1); assert.match(result.stderr, /expires on its own/); assert.match(result.stderr, /refused/);