mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat: Enable /setup-github to always run, and error appropriately (#5653)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -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.',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user