Skip to content

Commit e370593

Browse files
author
Chris Scott
committed
Replace URL token embedding with GIT_ASKPASS for git authentication
1 parent daf5754 commit e370593

3 files changed

Lines changed: 5 additions & 10 deletions

File tree

backend/src/services/git-operations.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function getGitEnvironment(database: Database): Record<string, string> {
2222
if (gitToken) {
2323
return {
2424
GITHUB_TOKEN: gitToken,
25-
GIT_ASKPASS: 'echo',
25+
GIT_ASKPASS: 'echo $GITHUB_TOKEN',
2626
GIT_TERMINAL_PROMPT: '0'
2727
}
2828
}

backend/src/services/opencode-single-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class OpenCodeServerManager {
9999
XDG_DATA_HOME: path.join(OPENCODE_SERVER_DIRECTORY, '.opencode/state'),
100100
OPENCODE_CONFIG: OPENCODE_CONFIG_PATH,
101101
GITHUB_TOKEN: gitToken,
102-
GIT_ASKPASS: 'echo',
102+
GIT_ASKPASS: gitToken ? 'echo $GITHUB_TOKEN' : 'echo',
103103
GIT_TERMINAL_PROMPT: '0'
104104
}
105105
}

backend/src/services/repo.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,7 @@ async function hasCommits(repoPath: string): Promise<boolean> {
1717
}
1818
}
1919

20-
function getAuthenticatedUrl(repoUrl: string, gitToken: string): string {
21-
if (gitToken && repoUrl.startsWith('https://github.com')) {
22-
return repoUrl.replace('https://', `https://${gitToken}@`)
23-
}
24-
return repoUrl
25-
}
20+
2621

2722
async function safeGetCurrentBranch(repoPath: string): Promise<string | null> {
2823
try {
@@ -88,7 +83,7 @@ export async function initLocalRepo(
8883
const env: Record<string, string> = gitToken ?
8984
{
9085
GITHUB_TOKEN: gitToken,
91-
GIT_ASKPASS: 'echo',
86+
GIT_ASKPASS: 'echo $GITHUB_TOKEN',
9287
GIT_TERMINAL_PROMPT: '0'
9388
} :
9489
{ GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: '0' }
@@ -176,7 +171,7 @@ export async function cloneRepo(
176171
const settings = settingsService.getSettings('default')
177172
const gitToken = settings.preferences.gitToken
178173

179-
const cloneUrl = getAuthenticatedUrl(repoUrl, gitToken || '')
174+
const cloneUrl = repoUrl
180175

181176
if (shouldUseWorktree) {
182177
logger.info(`Creating worktree for branch: ${branch}`)

0 commit comments

Comments
 (0)