summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee James <[email protected]>2025-08-06 09:06:37 -0400
committerGitHub <[email protected]>2025-08-06 13:06:37 +0000
commitb38f377c9a2672e88dd15119b38d908c0f00b54a (patch)
treef8cd37038f592ab31f501c9f85df7fc659ae4f64
parentaab850668c99e1c39a55036069d9f4b06ca458f4 (diff)
feat: Enable /setup-github to always run, and error appropriately (#5653)
Co-authored-by: Jacob Richman <[email protected]>
-rw-r--r--packages/cli/src/services/BuiltinCommandLoader.ts3
-rw-r--r--packages/cli/src/ui/commands/setupGithubCommand.test.ts4
-rw-r--r--packages/cli/src/ui/commands/setupGithubCommand.ts19
3 files changed, 18 insertions, 8 deletions
diff --git a/packages/cli/src/services/BuiltinCommandLoader.ts b/packages/cli/src/services/BuiltinCommandLoader.ts
index 46ecb37c..c09f7c61 100644
--- a/packages/cli/src/services/BuiltinCommandLoader.ts
+++ b/packages/cli/src/services/BuiltinCommandLoader.ts
@@ -32,7 +32,6 @@ import { themeCommand } from '../ui/commands/themeCommand.js';
import { toolsCommand } from '../ui/commands/toolsCommand.js';
import { vimCommand } from '../ui/commands/vimCommand.js';
import { setupGithubCommand } from '../ui/commands/setupGithubCommand.js';
-import { isGitHubRepository } from '../utils/gitUtils.js';
/**
* Loads the core, hard-coded slash commands that are an integral part
@@ -74,7 +73,7 @@ export class BuiltinCommandLoader implements ICommandLoader {
themeCommand,
toolsCommand,
vimCommand,
- ...(isGitHubRepository() ? [setupGithubCommand] : []),
+ setupGithubCommand,
];
return allDefinitions.filter((cmd): cmd is SlashCommand => cmd !== null);
diff --git a/packages/cli/src/ui/commands/setupGithubCommand.test.ts b/packages/cli/src/ui/commands/setupGithubCommand.test.ts
index 891c84e7..ae6378c7 100644
--- a/packages/cli/src/ui/commands/setupGithubCommand.test.ts
+++ b/packages/cli/src/ui/commands/setupGithubCommand.test.ts
@@ -61,6 +61,8 @@ describe('setupGithubCommand', () => {
vi.mocked(child_process.execSync).mockReturnValue('');
expect(() => {
setupGithubCommand.action?.({} as CommandContext, '');
- }).toThrow('Unable to determine the Git root directory.');
+ }).toThrow(
+ 'Unable to determine the GitHub repository. /setup-github must be run from a git repository.',
+ );
});
});
diff --git a/packages/cli/src/ui/commands/setupGithubCommand.ts b/packages/cli/src/ui/commands/setupGithubCommand.ts
index 445c0e76..047e11eb 100644
--- a/packages/cli/src/ui/commands/setupGithubCommand.ts
+++ b/packages/cli/src/ui/commands/setupGithubCommand.ts
@@ -19,12 +19,21 @@ export const setupGithubCommand: SlashCommand = {
description: 'Set up GitHub Actions',
kind: CommandKind.BUILT_IN,
action: (): SlashCommandActionReturn => {
- const gitRootRepo = execSync('git rev-parse --show-toplevel', {
- encoding: 'utf-8',
- }).trim();
-
if (!isGitHubRepository()) {
- throw new Error('Unable to determine the Git root directory.');
+ throw new Error(
+ 'Unable to determine the GitHub repository. /setup-github must be run from a git repository.',
+ );
+ }
+
+ let gitRootRepo: string;
+ try {
+ gitRootRepo = execSync('git rev-parse --show-toplevel', {
+ encoding: 'utf-8',
+ }).trim();
+ } catch {
+ throw new Error(
+ 'Unable to determine the GitHub repository. /setup-github must be run from a git repository.',
+ );
}
const version = 'v0';