From 6b1b6c741dcd8f11b27c42c369fe515856be8dc3 Mon Sep 17 00:00:00 2001 From: eric sciple Date: Mon, 27 Jan 2020 10:21:50 -0500 Subject: follow proxy settings (#144) --- src/git-source-provider.ts | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/git-source-provider.ts') diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 8c7aa15..e0dd58e 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -9,7 +9,8 @@ import * as refHelper from './ref-helper' import * as stateHelper from './state-helper' import {IGitCommandManager} from './git-command-manager' -const authConfigKey = `http.https://github.com/.extraheader` +const serverUrl = 'https://github.com/' +const authConfigKey = `http.${serverUrl}.extraheader` export interface ISourceSettings { repositoryPath: string @@ -95,7 +96,7 @@ export async function getSource(settings: ISourceSettings): Promise { await removeGitConfig(git, authConfigKey) try { - // Config auth token + // Config extraheader await configureAuthToken(git, settings.authToken) // LFS install @@ -136,16 +137,21 @@ export async function getSource(settings: ISourceSettings): Promise { export async function cleanup(repositoryPath: string): Promise { // Repo exists? - if (!fsHelper.fileExistsSync(path.join(repositoryPath, '.git', 'config'))) { + if ( + !repositoryPath || + !fsHelper.fileExistsSync(path.join(repositoryPath, '.git', 'config')) + ) { return } - fsHelper.directoryExistsSync(repositoryPath, true) - // Remove the config key - const git = await gitCommandManager.CreateCommandManager( - repositoryPath, - false - ) + let git: IGitCommandManager + try { + git = await gitCommandManager.CreateCommandManager(repositoryPath, false) + } catch { + return + } + + // Remove extraheader await removeGitConfig(git, authConfigKey) } -- cgit v1.2.3