Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/issue-shorthand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'gcb-client': patch
---

Add the `gcb issue <subcommand>` shorthand for catalogued issue actions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ gcb gh run view 123456 --log --repo owner/name

`-R` is the short form of `--repo`, as in `gh` itself.

`gcb pr <subcommand>` and `gcb run <subcommand>` are shorthands for the same actions when the
catalog has one — `gcb pr view 12`, `gcb pr close 12`, `gcb run list`. The flag-only `gcb pr` form
`gcb pr <subcommand>`, `gcb run <subcommand>` and `gcb issue <subcommand>` are shorthands for the
same actions when the catalog has one — `gcb pr view 12`, `gcb pr close 12`, `gcb run list`,
`gcb issue create --repo owner/name --title "A title" --body "A body"`. The flag-only `gcb pr` form
described below is still what runs the lifecycle `gh` cannot express (opening as a person, review
threads); `gcb pr --close` is gone and refuses with a pointer at `gcb gh pr close`.

Expand Down
7 changes: 4 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,10 @@ host_broker:
- built-ins first (`setup`, `init`, `stage`, `compose`, `probe`, `diagnose`, `authorize`,
`app`, `host`, `config`, `version`, `help`);
- `gcb gh …` explicit;
- `gcb pr view …`, `gcb run view …` etc. resolve to the `gh` subcommand. (Wired: any `pr`
subcommand the catalog has, plus `run`; the flag-only `gcb pr` stays for the lifecycle `gh`
cannot express, and `--close` refuses with a pointer at `gcb gh pr close`.)
- `gcb pr view …`, `gcb run view …`, `gcb issue create …` etc. resolve to the `gh`
subcommand. (Wired: any `pr` subcommand the catalog has, plus `run` and `issue`; the
flag-only `gcb pr` stays for the lifecycle `gh` cannot express, and `--close` refuses with a
pointer at `gcb gh pr close`.)
- [ ] Remove the built-in `pr` and `logs` commands. `gcb run view --job <id> --log` replaces `logs`.
- [x] Build the command table. Every entry has:
- canonical subcommand (no aliases, no abbreviations);
Expand Down
3 changes: 2 additions & 1 deletion packages/client/src/commands/gh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ function repoFromCheckout(cwd: string): { repo: string; host: string } | undefin
export const GH_USAGE = `Usage: gcb gh <domain> <command> [options]

Run a catalogued GitHub action through the broker.
gcb pr <subcommand> and gcb run <subcommand> are shorthands for the same actions.
gcb pr <subcommand>, gcb run <subcommand> and gcb issue <subcommand> are shorthands for the same
actions.

Common
-R, --repo <owner/name> Repository the action belongs to (default: origin remote)
Expand Down
7 changes: 5 additions & 2 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* The host commands are not imported here; installing `gcb-client` never pulls `yaml`.
*/
import { GH_ACTIONS } from 'gcb-core';
import { CLIENT_COMMANDS, GH_ACTIONS } from 'gcb-core';
import type { CommandBackend } from 'gcb-core';

export { runHelper } from './helper.ts';
Expand Down Expand Up @@ -35,6 +35,7 @@ Commands
pr Use the broker's pull-request lifecycle; these run as gh actions:
${cataloguedSubcommands('pr')}
run Run a workflow run action: ${cataloguedSubcommands('run')}
issue Run an issue action: ${cataloguedSubcommands('issue')}
gh Run a catalogued GitHub action through the broker

As a git credential helper
Expand Down Expand Up @@ -74,6 +75,8 @@ async function run(argv: readonly string[]): Promise<number> {
}
case 'run':
return (await import('./commands/gh.ts')).runGh(['run', ...rest]);
case 'issue':
return (await import('./commands/gh.ts')).runGh(['issue', ...rest]);
case 'gh':
return (await import('./commands/gh.ts')).runGh(rest);
default:
Expand All @@ -84,7 +87,7 @@ async function run(argv: readonly string[]): Promise<number> {

export const clientBackend: CommandBackend = {
role: 'client',
commands: ['setup', 'probe', 'logs', 'pr', 'run', 'gh'],
commands: CLIENT_COMMANDS,
help: CLIENT_HELP,
run,
};
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { platformRefusal } from './platform.ts';
import { PACKAGE_VERSION } from './version.ts';

/** Commands implemented by the container-side package. */
export const CLIENT_COMMANDS = ['setup', 'probe', 'logs', 'pr', 'run', 'gh'] as const;
export const CLIENT_COMMANDS = ['setup', 'probe', 'logs', 'pr', 'run', 'issue', 'gh'] as const;

/** Commands implemented by the host-side package. */
export const HOST_COMMANDS = [
Expand Down
8 changes: 6 additions & 2 deletions test/unit/gh-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ describe('gcb gh', () => {
}
});

it('routes pr subcommands and run through the gh action', async () => {
it('routes pr, run and issue subcommands through the gh action', async () => {
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'gcb-gh-shorthand-'));
const socketPath = path.join(root, 'broker.sock');
const block: StaticHostConfig = { provider: 'static', allow: ['acme/widget'] };
Expand Down Expand Up @@ -236,7 +236,11 @@ describe('gcb gh', () => {
assert.equal(close.status, 0);
const run = await runClient(['run', 'list', '--repo', 'acme/widget', '--socket', socketPath]);
assert.equal(run.status, 0);
assert.deepEqual(actions, ['pr:view', 'pr:close', 'run:list']);
const issue = await runClient([
'issue', 'create', '--repo', 'acme/widget', '--title', 't', '--body', 'b', '--socket', socketPath,
]);
assert.equal(issue.status, 0);
assert.deepEqual(actions, ['pr:view', 'pr:close', 'run:list', 'issue:create']);
} finally {
await broker.close();
fs.rmSync(root, { recursive: true, force: true });
Expand Down
Loading