mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
Replace URL token embedding with GIT_ASKPASS for git authentication
This commit is contained in:
1 parent
daf5754cc1
commit
e37059360a
3 files changed
+5
-10
No files matched your search
@@ -22,7 +22,7 @@ function getGitEnvironment(database: Database): Record<string, string> {
|
||||
if (gitToken) {
|
||||
return {
|
||||
GITHUB_TOKEN: gitToken,
|
||||
GIT_ASKPASS: 'echo',
|
||||
GIT_ASKPASS: 'echo $GITHUB_TOKEN',
|
||||
GIT_TERMINAL_PROMPT: '0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ class OpenCodeServerManager {
|
||||
XDG_DATA_HOME: path.join(OPENCODE_SERVER_DIRECTORY, '.opencode/state'),
|
||||
OPENCODE_CONFIG: OPENCODE_CONFIG_PATH,
|
||||
GITHUB_TOKEN: gitToken,
|
||||
GIT_ASKPASS: 'echo',
|
||||
GIT_ASKPASS: gitToken ? 'echo $GITHUB_TOKEN' : 'echo',
|
||||
GIT_TERMINAL_PROMPT: '0'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,7 @@ async function hasCommits(repoPath: string): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
function getAuthenticatedUrl(repoUrl: string, gitToken: string): string {
|
||||
if (gitToken && repoUrl.startsWith('https://github.com')) {
|
||||
return repoUrl.replace('https://', `https://${gitToken}@`)
|
||||
}
|
||||
return repoUrl
|
||||
}
|
||||
|
||||
|
||||
async function safeGetCurrentBranch(repoPath: string): Promise<string | null> {
|
||||
try {
|
||||
@@ -88,7 +83,7 @@ export async function initLocalRepo(
|
||||
const env: Record<string, string> = gitToken ?
|
||||
{
|
||||
GITHUB_TOKEN: gitToken,
|
||||
GIT_ASKPASS: 'echo',
|
||||
GIT_ASKPASS: 'echo $GITHUB_TOKEN',
|
||||
GIT_TERMINAL_PROMPT: '0'
|
||||
} :
|
||||
{ GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: '0' }
|
||||
@@ -176,7 +171,7 @@ export async function cloneRepo(
|
||||
const settings = settingsService.getSettings('default')
|
||||
const gitToken = settings.preferences.gitToken
|
||||
|
||||
const cloneUrl = getAuthenticatedUrl(repoUrl, gitToken || '')
|
||||
const cloneUrl = repoUrl
|
||||
|
||||
if (shouldUseWorktree) {
|
||||
logger.info(`Creating worktree for branch: ${branch}`)
|
||||
|
||||
Reference in new issue
Block a user