mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
feat: open repo secrets page in addition to README (#5684)
This commit is contained in:
@@ -18,6 +18,7 @@ vi.mock('../../utils/gitUtils.js', () => ({
|
||||
isGitHubRepository: vi.fn(),
|
||||
getGitRepoRoot: vi.fn(),
|
||||
getLatestGitHubRelease: vi.fn(),
|
||||
getGitHubRepoInfo: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('setupGithubCommand', async () => {
|
||||
@@ -30,7 +31,9 @@ describe('setupGithubCommand', async () => {
|
||||
});
|
||||
|
||||
it('returns a tool action to download github workflows and handles paths', async () => {
|
||||
const fakeRepoRoot = '/github.com/fake/repo/root';
|
||||
const fakeRepoOwner = 'fake';
|
||||
const fakeRepoName = 'repo';
|
||||
const fakeRepoRoot = `/github.com/${fakeRepoOwner}/${fakeRepoName}/root`;
|
||||
const fakeReleaseVersion = 'v1.2.3';
|
||||
|
||||
vi.mocked(gitUtils.isGitHubRepository).mockReturnValueOnce(true);
|
||||
@@ -38,6 +41,10 @@ describe('setupGithubCommand', async () => {
|
||||
vi.mocked(gitUtils.getLatestGitHubRelease).mockResolvedValueOnce(
|
||||
fakeReleaseVersion,
|
||||
);
|
||||
vi.mocked(gitUtils.getGitHubRepoInfo).mockReturnValue({
|
||||
owner: fakeRepoOwner,
|
||||
repo: fakeRepoName,
|
||||
});
|
||||
|
||||
const result = (await setupGithubCommand.action?.(
|
||||
{} as CommandContext,
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
getGitRepoRoot,
|
||||
getLatestGitHubRelease,
|
||||
isGitHubRepository,
|
||||
getGitHubRepoInfo,
|
||||
} from '../../utils/gitUtils.js';
|
||||
|
||||
import {
|
||||
@@ -18,6 +19,27 @@ import {
|
||||
SlashCommand,
|
||||
SlashCommandActionReturn,
|
||||
} from './types.js';
|
||||
import { getUrlOpenCommand } from '../../ui/utils/commandUtils.js';
|
||||
|
||||
// Generate OS-specific commands to open the GitHub pages needed for setup.
|
||||
function getOpenUrlsCommands(readmeUrl: string): string[] {
|
||||
// Determine the OS-specific command to open URLs, ex: 'open', 'xdg-open', etc
|
||||
const openCmd = getUrlOpenCommand();
|
||||
|
||||
// Build a list of URLs to open
|
||||
const urlsToOpen = [readmeUrl];
|
||||
|
||||
const repoInfo = getGitHubRepoInfo();
|
||||
if (repoInfo) {
|
||||
urlsToOpen.push(
|
||||
`https://github.com/${repoInfo.owner}/${repoInfo.repo}/settings/secrets/actions`,
|
||||
);
|
||||
}
|
||||
|
||||
// Create and join the individual commands
|
||||
const commands = urlsToOpen.map((url) => `${openCmd} "${url}"`);
|
||||
return commands;
|
||||
}
|
||||
|
||||
export const setupGithubCommand: SlashCommand = {
|
||||
name: 'setup-github',
|
||||
@@ -71,11 +93,14 @@ export const setupGithubCommand: SlashCommand = {
|
||||
commands.push(curlCommand);
|
||||
}
|
||||
|
||||
const readmeUrl = `https://github.com/google-github-actions/run-gemini-cli/blob/${releaseTag}/README.md#quick-start`;
|
||||
|
||||
commands.push(
|
||||
`echo "Successfully downloaded ${workflows.length} workflows. Follow the steps in https://github.com/google-github-actions/run-gemini-cli/blob/${releaseTag}/README.md#quick-start (skipping the /setup-github step) to complete setup."`,
|
||||
`open https://github.com/google-github-actions/run-gemini-cli/blob/${releaseTag}/README.md#quick-start`,
|
||||
`echo "Successfully downloaded ${workflows.length} workflows. Follow the steps in ${readmeUrl} (skipping the /setup-github step) to complete setup."`,
|
||||
);
|
||||
|
||||
commands.push(...getOpenUrlsCommands(readmeUrl));
|
||||
|
||||
const command = `(${commands.join(' && ')})`;
|
||||
return {
|
||||
type: 'tool',
|
||||
|
||||
Reference in New Issue
Block a user