From f367d0fe2067d0603210b0a10ef104bc01449087 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Thu, 17 Oct 2019 16:19:26 +0200 Subject: [PATCH] skip auth only for auto fetch related to #72615 --- extensions/git/src/askpass-main.ts | 4 ++++ extensions/git/src/autofetch.ts | 2 +- extensions/git/src/git.ts | 9 +++++++-- extensions/git/src/repository.ts | 4 ++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/extensions/git/src/askpass-main.ts b/extensions/git/src/askpass-main.ts index 6ad5f94109e..c08aa2a0afc 100644 --- a/extensions/git/src/askpass-main.ts +++ b/extensions/git/src/askpass-main.ts @@ -28,6 +28,10 @@ function main(argv: string[]): void { return fatal('Missing pipe'); } + if (process.env['VSCODE_GIT_COMMAND'] === 'fetch' && !!process.env['VSCODE_GIT_FETCH_SILENT']) { + return fatal('Skip silent fetch commands'); + } + const output = process.env['VSCODE_GIT_ASKPASS_PIPE'] as string; const socketPath = process.env['VSCODE_GIT_ASKPASS_HANDLE'] as string; const request = argv[2]; diff --git a/extensions/git/src/autofetch.ts b/extensions/git/src/autofetch.ts index 9fd81bfabfe..d9e436b9f5c 100644 --- a/extensions/git/src/autofetch.ts +++ b/extensions/git/src/autofetch.ts @@ -99,7 +99,7 @@ export class AutoFetcher { } try { - await this.repository.fetchDefault(); + await this.repository.fetchDefault({ silent: true }); } catch (err) { if (err.gitErrorCode === GitErrorCodes.AuthenticationFailed) { this.disable(); diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 0696a0af5cd..dd10c0a8f4c 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -1401,8 +1401,9 @@ export class Repository { await this.run(args); } - async fetch(options: { remote?: string, ref?: string, all?: boolean, prune?: boolean, depth?: number } = {}): Promise { + async fetch(options: { remote?: string, ref?: string, all?: boolean, prune?: boolean, depth?: number, silent?: boolean } = {}): Promise { const args = ['fetch']; + const spawnOptions: SpawnOptions = {}; if (options.remote) { args.push(options.remote); @@ -1422,8 +1423,12 @@ export class Repository { args.push(`--depth=${options.depth}`); } + if (options.silent) { + spawnOptions.env = { 'VSCODE_GIT_FETCH_SILENT': 'true' }; + } + try { - await this.run(args); + await this.run(args, spawnOptions); } catch (err) { if (/No remote repository specified\./.test(err.stderr || '')) { err.gitErrorCode = GitErrorCodes.NoRemoteRepositorySpecified; diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 6f792d34cd7..2f52423d077 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -1054,8 +1054,8 @@ export class Repository implements Disposable { } @throttle - async fetchDefault(): Promise { - await this.run(Operation.Fetch, () => this.repository.fetch()); + async fetchDefault(options: { silent?: boolean } = {}): Promise { + await this.run(Operation.Fetch, () => this.repository.fetch(options)); } @throttle -- GitLab