Browse Source

Adds native fetch call

Puts fetch behind flag
main
Ramin Tadayon 1 year ago
parent
commit
4e918c8bec
No known key found for this signature in database GPG Key ID: 79D60DDE3DFB95F5
3 changed files with 24 additions and 1 deletions
  1. +7
    -0
      src/env/node/git/git.ts
  2. +16
    -0
      src/env/node/git/localGitProvider.ts
  3. +1
    -1
      src/git/models/repository.ts

+ 7
- 0
src/env/node/git/git.ts View File

@ -136,6 +136,7 @@ export class Git {
// Shouldn't *really* be needed but better safe than sorry
env: {
...process.env,
...this._gitEnv,
...(options.env ?? emptyObj),
GCM_INTERACTIVE: 'NEVER',
GCM_PRESERVE_CREDS: 'TRUE',
@ -240,6 +241,7 @@ export class Git {
// Shouldn't *really* be needed but better safe than sorry
env: {
...process.env,
...this._gitEnv,
...(options.env ?? emptyObj),
GCM_INTERACTIVE: 'NEVER',
GCM_PRESERVE_CREDS: 'TRUE',
@ -322,6 +324,11 @@ export class Git {
this._gitLocation = undefined;
}
private _gitEnv: Record<string, unknown> | undefined;
setEnv(env: Record<string, unknown> | undefined): void {
this._gitEnv = env;
}
async path(): Promise<string> {
return (await this.getLocation()).path;
}

+ 16
- 0
src/env/node/git/localGitProvider.ts View File

@ -326,6 +326,22 @@ export class LocalGitProvider implements GitProvider, Disposable {
const scmGit = await scmGitPromise;
if (scmGit == null) return;
// Find env to pass to Git
if (configuration.getAny('gitlens.experimental.nativeGit') === true) {
for (const v of Object.values(scmGit.git)) {
if (v != null && typeof v === 'object' && 'git' in v) {
for (const vv of Object.values(v.git)) {
if (vv != null && typeof vv === 'object' && 'GIT_ASKPASS' in vv) {
Logger.debug(scope, 'Found built-in Git env');
this.git.setEnv(vv);
break;
}
}
}
}
}
this._disposables.push(
// Since we will get "close" events for repos when vscode is shutting down, debounce the event so ensure we aren't shutting down
scmGit.onDidCloseRepository(

+ 1
- 1
src/git/models/repository.ts View File

@ -577,7 +577,7 @@ export class Repository implements Disposable {
remote?: string;
}) {
try {
if (options?.branch != null) {
if (configuration.getAny('gitlens.experimental.nativeGit') === true || options?.branch != null) {
await this.container.git.fetch(this.path, options);
} else {
void (await executeCoreGitCommand('git.fetch', this.path));

Loading…
Cancel
Save