@gitkraken/core-gitlens 0.31.0 → 0.33.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -1
- package/dist/git/cache.d.ts +90 -15
- package/dist/git/cache.js +215 -44
- package/dist/git/cache.js.map +1 -1
- package/dist/git/models/repositoryIdentities.d.ts +0 -1
- package/dist/git/models/repositoryIdentities.js +1 -4
- package/dist/git/models/repositoryIdentities.js.map +1 -1
- package/dist/git/providers/config.d.ts +8 -0
- package/dist/git/providers/provider.d.ts +7 -0
- package/dist/git/remotes/gitlab.js +15 -9
- package/dist/git/remotes/gitlab.js.map +1 -1
- package/dist/git/service.d.ts +2 -1
- package/dist/git/service.js +6 -2
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/repository.utils.d.ts +10 -0
- package/dist/git/utils/repository.utils.js +25 -2
- package/dist/git/utils/repository.utils.js.map +1 -1
- package/dist/git/watching/changeEvent.d.ts +13 -3
- package/dist/git/watching/changeEvent.js +19 -4
- package/dist/git/watching/changeEvent.js.map +1 -1
- package/dist/git/watching/watchGroup.d.ts +4 -2
- package/dist/git/watching/watchGroup.js +32 -17
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +4 -1
- package/dist/git/watching/watchService.js +18 -15
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watchSession.d.ts +27 -12
- package/dist/git/watching/watchSession.js +49 -19
- package/dist/git/watching/watchSession.js.map +1 -1
- package/dist/git/watching/worktreeSummary.d.ts +3 -2
- package/dist/git/watching/worktreeSummary.js +11 -10
- package/dist/git/watching/worktreeSummary.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +28 -2
- package/dist/git-cli/cliGitProvider.js +63 -20
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.d.ts +17 -1
- package/dist/git-cli/exec/git.js +55 -8
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/indexLock.d.ts +2 -0
- package/dist/git-cli/exec/indexLock.js +2 -2
- package/dist/git-cli/exec/indexLock.js.map +1 -1
- package/dist/git-cli/providers/branches.js +15 -10
- package/dist/git-cli/providers/branches.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +6 -1
- package/dist/git-cli/providers/config.js +49 -48
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.js +7 -3
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/worktrees.js +34 -10
- package/dist/git-cli/providers/worktrees.js.map +1 -1
- package/dist/git-cli/service.js +1 -1
- package/dist/git-cli/service.js.map +1 -1
- package/dist/plus/integrations/models/integration.js +1 -1
- package/dist/plus/integrations/models/integration.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +10 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.js +62 -15
- package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.d.ts +8 -0
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js +32 -16
- package/dist/plus/integrations/providers/gitlab/gitlab.utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -120,8 +120,10 @@ export declare class ConfigGitSubProvider implements GitConfigSubProvider {
|
|
|
120
120
|
}): Promise<void>;
|
|
121
121
|
private setConfigCore;
|
|
122
122
|
getCurrentUser(repoPath: string): Promise<GitUser | undefined>;
|
|
123
|
+
private readCurrentUser;
|
|
123
124
|
getDefaultWorktreePath(repoPath: string): Promise<string | undefined>;
|
|
124
125
|
getGitDir(repoPath: string): Promise<GitDir>;
|
|
126
|
+
private readGitDir;
|
|
125
127
|
/** The git dirs {@link getRepositoryInfo} would report for `repoPath`, when they can be read without running git */
|
|
126
128
|
private readGitDirsWithoutGit;
|
|
127
129
|
/**
|
|
@@ -202,13 +204,16 @@ export declare class ConfigGitSubProvider implements GitConfigSubProvider {
|
|
|
202
204
|
global?: boolean;
|
|
203
205
|
}): Promise<void>;
|
|
204
206
|
getSigningConfigFlags(config: SigningConfig): string[];
|
|
207
|
+
/**
|
|
208
|
+
* `[]` when git says `cwd` isn't a repository it can use, or `cwd` isn't a folder. Rejects when git gives no answer
|
|
209
|
+
* (it ran past its time limit, was killed or couldn't start), which says nothing about `cwd`.
|
|
210
|
+
*/
|
|
205
211
|
getRepositoryInfo(cwd: string): Promise<{
|
|
206
212
|
repoPath: string;
|
|
207
213
|
gitDir: string;
|
|
208
214
|
commonGitDir: string | undefined;
|
|
209
215
|
superprojectPath: string | undefined;
|
|
210
216
|
} | [safe: true, repoPath: string] | [safe: false] | []>;
|
|
211
|
-
private revParseGitDir;
|
|
212
217
|
/**
|
|
213
218
|
* Ensures the `.git/gk/` folder exists, but only if the parent `.git` directory already exists.
|
|
214
219
|
* This prevents creating stray `.git` directories if the computed path is wrong.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { first, some } from "../../utils/iterable.js";
|
|
2
|
-
import { CancellationError } from "../../utils/cancellation.js";
|
|
2
|
+
import { CancellationError, isCancellationError } from "../../utils/cancellation.js";
|
|
3
3
|
import { Logger as _logger } from "../../utils/logger.js";
|
|
4
4
|
import { getScopedLogger } from "../../utils/logger.scoped.js";
|
|
5
5
|
import { getSettledValue } from "../../utils/promise.js";
|
|
@@ -12,6 +12,7 @@ import { WorkspaceUntrustedError } from "../../git/errors.js";
|
|
|
12
12
|
import { fsExists } from "../../utils/env/node/exec.js";
|
|
13
13
|
import { isGitDirMovedByEnv, readGitDirs } from "../exec/gitDirResolver.js";
|
|
14
14
|
import { KeyedSequencer } from "../exec/indexLock.js";
|
|
15
|
+
import { isFolder, isGitAnswer, isGitUnanswered, throwIfUnanswered } from "../exec/git.js";
|
|
15
16
|
import { gate } from "../../utils/decorators/gate.js";
|
|
16
17
|
import { promises, statSync } from "fs";
|
|
17
18
|
import { env } from "process";
|
|
@@ -316,6 +317,12 @@ var ConfigGitSubProvider = class {
|
|
|
316
317
|
const cached = this.cache.currentUser.get(repoPath);
|
|
317
318
|
if (cached != null) return cached;
|
|
318
319
|
if (cached === null) return void 0;
|
|
320
|
+
return this.readCurrentUser(repoPath, this.cache.getDropStamp("currentUser", repoPath), scope);
|
|
321
|
+
}
|
|
322
|
+
async readCurrentUser(repoPath, dropStamp, scope) {
|
|
323
|
+
const setCachedUser = (value) => {
|
|
324
|
+
if (!this.cache.isDroppedSince("currentUser", repoPath, dropStamp)) this.cache.currentUser.set(repoPath, value);
|
|
325
|
+
};
|
|
319
326
|
const user = {
|
|
320
327
|
name: void 0,
|
|
321
328
|
email: void 0
|
|
@@ -328,7 +335,7 @@ var ConfigGitSubProvider = class {
|
|
|
328
335
|
} else {
|
|
329
336
|
user.name = env.GIT_AUTHOR_NAME || env.GIT_COMMITTER_NAME || userInfo()?.username || void 0;
|
|
330
337
|
if (!user.name) {
|
|
331
|
-
|
|
338
|
+
setCachedUser(null);
|
|
332
339
|
return;
|
|
333
340
|
}
|
|
334
341
|
user.email = env.GIT_AUTHOR_EMAIL || env.GIT_COMMITTER_EMAIL || env.EMAIL || `${user.name}@${hostname()}`;
|
|
@@ -342,16 +349,16 @@ var ConfigGitSubProvider = class {
|
|
|
342
349
|
const match = mappedAuthorRegex.exec(result.stdout);
|
|
343
350
|
if (match != null) [, user.name, user.email] = match;
|
|
344
351
|
}
|
|
345
|
-
|
|
352
|
+
setCachedUser(user);
|
|
346
353
|
return user;
|
|
347
354
|
} catch (ex) {
|
|
348
355
|
scope?.error(ex);
|
|
349
|
-
|
|
356
|
+
setCachedUser(null);
|
|
350
357
|
return;
|
|
351
358
|
}
|
|
352
359
|
}
|
|
353
360
|
async getDefaultWorktreePath(repoPath) {
|
|
354
|
-
const gitDir = await this.getGitDir(repoPath);
|
|
361
|
+
const gitDir = await this.getGitDir(repoPath).catch(() => void 0);
|
|
355
362
|
if (gitDir == null) return void 0;
|
|
356
363
|
const basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;
|
|
357
364
|
return getBestPath(normalizePath(joinPaths(basePath, "..")));
|
|
@@ -360,6 +367,9 @@ var ConfigGitSubProvider = class {
|
|
|
360
367
|
const cached = this.cache.gitDir.get(repoPath);
|
|
361
368
|
if (cached != null) return cached;
|
|
362
369
|
const scope = getScopedLogger();
|
|
370
|
+
return this.readGitDir(repoPath, this.cache.getCloseGeneration(repoPath), scope);
|
|
371
|
+
}
|
|
372
|
+
async readGitDir(repoPath, closeGeneration, scope) {
|
|
363
373
|
let gitDir;
|
|
364
374
|
const fsGitDirs = await this.readGitDirsWithoutGit(repoPath);
|
|
365
375
|
if (fsGitDirs != null) {
|
|
@@ -370,7 +380,7 @@ var ConfigGitSubProvider = class {
|
|
|
370
380
|
commonUri: commonPath !== path ? fileUri(commonPath) : void 0,
|
|
371
381
|
parentUri: void 0
|
|
372
382
|
};
|
|
373
|
-
this.cache.gitDir.set(repoPath, gitDir);
|
|
383
|
+
if (this.cache.getCloseGeneration(repoPath) === closeGeneration) this.cache.gitDir.set(repoPath, gitDir);
|
|
374
384
|
return gitDir;
|
|
375
385
|
}
|
|
376
386
|
const repoInfo = await this.getRepositoryInfo(repoPath);
|
|
@@ -385,7 +395,7 @@ var ConfigGitSubProvider = class {
|
|
|
385
395
|
scope?.warn(`rev-parse failed for '${repoPath}'; falling back to '${gitDirPath}'`);
|
|
386
396
|
this.context.hooks?.operations?.onGitDirResolveFailed?.(repoPath, gitDirPath, `rev_parse returned ${JSON.stringify(repoInfo)}`);
|
|
387
397
|
}
|
|
388
|
-
this.cache.gitDir.set(repoPath, gitDir);
|
|
398
|
+
if (this.cache.getCloseGeneration(repoPath) === closeGeneration) this.cache.gitDir.set(repoPath, gitDir);
|
|
389
399
|
return gitDir;
|
|
390
400
|
}
|
|
391
401
|
/** The git dirs {@link getRepositoryInfo} would report for `repoPath`, when they can be read without running git */
|
|
@@ -399,7 +409,9 @@ var ConfigGitSubProvider = class {
|
|
|
399
409
|
* Uses commonPath for worktrees so all worktrees share the same data.
|
|
400
410
|
*/
|
|
401
411
|
async getGkConfigPath(repoPath) {
|
|
402
|
-
const gitDir = await this.getGitDir(repoPath)
|
|
412
|
+
const gitDir = await this.getGitDir(repoPath).catch((ex) => {
|
|
413
|
+
_logger.warn(`Unable to locate GitKraken config storage for '${repoPath}': ${String(ex)}`);
|
|
414
|
+
});
|
|
403
415
|
if (gitDir == null) return void 0;
|
|
404
416
|
const basePath = (gitDir.commonUri ?? gitDir.uri).fsPath;
|
|
405
417
|
return joinPaths(basePath, "gk", "config");
|
|
@@ -496,7 +508,7 @@ var ConfigGitSubProvider = class {
|
|
|
496
508
|
read.spawned = true;
|
|
497
509
|
return {
|
|
498
510
|
map: /* @__PURE__ */ new Map(),
|
|
499
|
-
failed:
|
|
511
|
+
failed: true
|
|
500
512
|
};
|
|
501
513
|
}
|
|
502
514
|
read.path = gkConfigPath;
|
|
@@ -725,6 +737,10 @@ var ConfigGitSubProvider = class {
|
|
|
725
737
|
if (config.allowedSignersFile) flags.push("-c", `gpg.ssh.allowedSignersFile=${config.allowedSignersFile}`);
|
|
726
738
|
return flags;
|
|
727
739
|
}
|
|
740
|
+
/**
|
|
741
|
+
* `[]` when git says `cwd` isn't a repository it can use, or `cwd` isn't a folder. Rejects when git gives no answer
|
|
742
|
+
* (it ran past its time limit, was killed or couldn't start), which says nothing about `cwd`.
|
|
743
|
+
*/
|
|
728
744
|
async getRepositoryInfo(cwd) {
|
|
729
745
|
let result;
|
|
730
746
|
if (this.context.workspace?.isTrusted === false) try {
|
|
@@ -738,7 +754,9 @@ var ConfigGitSubProvider = class {
|
|
|
738
754
|
_logger.warn(`Skipping (untrusted); bare clone repository detected in '${cwd}'`);
|
|
739
755
|
return emptyArray;
|
|
740
756
|
}
|
|
741
|
-
} catch {
|
|
757
|
+
} catch (ex) {
|
|
758
|
+
if (isGitUnanswered(ex)) throw ex;
|
|
759
|
+
}
|
|
742
760
|
try {
|
|
743
761
|
result = await this.git.run({
|
|
744
762
|
cwd,
|
|
@@ -766,6 +784,7 @@ var ConfigGitSubProvider = class {
|
|
|
766
784
|
};
|
|
767
785
|
} catch (ex) {
|
|
768
786
|
if (ex instanceof WorkspaceUntrustedError) return emptyArray;
|
|
787
|
+
if (!isGitAnswer(ex) && (isCancellationError(ex) || await isFolder(cwd))) throw ex;
|
|
769
788
|
const unsafeMatch = /(?:^fatal:\s*detected dubious ownership in repository at '([^']+)'|unsafe repository \('([^']+)' is owned by someone else\))[\s\S]*(git config --global --add safe\.directory [^\n\u2022]+)/m.exec(ex.stderr);
|
|
770
789
|
if (unsafeMatch != null) {
|
|
771
790
|
_logger.warn(`Skipping; unsafe repository detected in '${unsafeMatch[1] || unsafeMatch[2]}'; run '${unsafeMatch[3]}' to allow it`);
|
|
@@ -777,8 +796,12 @@ var ConfigGitSubProvider = class {
|
|
|
777
796
|
cwd,
|
|
778
797
|
errors: "ignore"
|
|
779
798
|
}, "rev-parse", "--is-bare-repository");
|
|
799
|
+
throwIfUnanswered(result);
|
|
780
800
|
if (result.stdout.trim() === "true") {
|
|
781
|
-
const result = await this.
|
|
801
|
+
const result = await this.git.rev_parse__git_dir(cwd).catch((ex) => {
|
|
802
|
+
if (isGitAnswer(ex)) return void 0;
|
|
803
|
+
throw ex;
|
|
804
|
+
});
|
|
782
805
|
const repoPath = result?.commonPath ?? result?.path;
|
|
783
806
|
if (repoPath?.length) {
|
|
784
807
|
const workTree = await this.git.rev_parse__work_tree_of_git_dir(repoPath);
|
|
@@ -786,40 +809,19 @@ var ConfigGitSubProvider = class {
|
|
|
786
809
|
}
|
|
787
810
|
}
|
|
788
811
|
}
|
|
789
|
-
if (inDotGit
|
|
790
|
-
let exists =
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
return this.getRepositoryInfo(cwd);
|
|
799
|
-
}
|
|
812
|
+
if (inDotGit) {
|
|
813
|
+
let exists = false;
|
|
814
|
+
do {
|
|
815
|
+
const parent = dirname(cwd);
|
|
816
|
+
if (parent === cwd || parent.length === 0) return emptyArray;
|
|
817
|
+
cwd = parent;
|
|
818
|
+
exists = await fsExists(cwd);
|
|
819
|
+
} while (!exists);
|
|
820
|
+
return this.getRepositoryInfo(cwd);
|
|
800
821
|
}
|
|
801
822
|
return emptyArray;
|
|
802
823
|
}
|
|
803
824
|
}
|
|
804
|
-
async revParseGitDir(cwd) {
|
|
805
|
-
const result = await this.git.run({
|
|
806
|
-
cwd,
|
|
807
|
-
errors: "ignore"
|
|
808
|
-
}, "rev-parse", "--git-dir", "--git-common-dir");
|
|
809
|
-
if (!result.stdout) return void 0;
|
|
810
|
-
let [dotGitPath, commonDotGitPath] = result.stdout.split("\n").map((r) => r.trimStart());
|
|
811
|
-
if (!isAbsolute(dotGitPath)) dotGitPath = joinPaths(cwd, dotGitPath);
|
|
812
|
-
dotGitPath = normalizePath(dotGitPath);
|
|
813
|
-
if (commonDotGitPath) {
|
|
814
|
-
if (!isAbsolute(commonDotGitPath)) commonDotGitPath = joinPaths(cwd, commonDotGitPath);
|
|
815
|
-
commonDotGitPath = normalizePath(commonDotGitPath);
|
|
816
|
-
return {
|
|
817
|
-
path: dotGitPath,
|
|
818
|
-
commonPath: commonDotGitPath !== dotGitPath ? commonDotGitPath : void 0
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
return { path: dotGitPath };
|
|
822
|
-
}
|
|
823
825
|
/**
|
|
824
826
|
* Ensures the `.git/gk/` folder exists, but only if the parent `.git` directory already exists.
|
|
825
827
|
* This prevents creating stray `.git` directories if the computed path is wrong.
|
|
@@ -852,10 +854,7 @@ var ConfigGitSubProvider = class {
|
|
|
852
854
|
if (this._migratedRepos.has(repoPath)) return;
|
|
853
855
|
const scope = getScopedLogger();
|
|
854
856
|
const gkConfigPath = await this.getGkConfigPath(repoPath);
|
|
855
|
-
if (!gkConfigPath)
|
|
856
|
-
this._migratedRepos.add(repoPath);
|
|
857
|
-
return;
|
|
858
|
-
}
|
|
857
|
+
if (!gkConfigPath) return;
|
|
859
858
|
const gkConfigFolder = joinPaths(gkConfigPath, "..");
|
|
860
859
|
try {
|
|
861
860
|
await promises.stat(gkConfigPath);
|
|
@@ -905,15 +904,17 @@ __decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getIgnoreC
|
|
|
905
904
|
__decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getConfigRegex", null);
|
|
906
905
|
__decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getConfigRegexAll", null);
|
|
907
906
|
__decorate([debug()], ConfigGitSubProvider.prototype, "setConfig", null);
|
|
908
|
-
__decorate([
|
|
909
|
-
__decorate([gate(),
|
|
907
|
+
__decorate([debug({ quiet: true })], ConfigGitSubProvider.prototype, "getCurrentUser", null);
|
|
908
|
+
__decorate([gate((repoPath, dropStamp) => `${repoPath}|${dropStamp}`)], ConfigGitSubProvider.prototype, "readCurrentUser", null);
|
|
909
|
+
__decorate([trace({
|
|
910
910
|
quiet: true,
|
|
911
911
|
exit: (r) => `returned ${r}`
|
|
912
912
|
})], ConfigGitSubProvider.prototype, "getDefaultWorktreePath", null);
|
|
913
|
-
__decorate([
|
|
913
|
+
__decorate([trace({
|
|
914
914
|
quiet: true,
|
|
915
915
|
exit: (r) => `returned ${r.uri.toString(true)}, commonUri=${r.commonUri?.toString(true)}, parentUri=${r.parentUri?.toString(true)}`
|
|
916
916
|
})], ConfigGitSubProvider.prototype, "getGitDir", null);
|
|
917
|
+
__decorate([gate((repoPath, closeGeneration) => `${repoPath}|${closeGeneration}`)], ConfigGitSubProvider.prototype, "readGitDir", null);
|
|
917
918
|
__decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getGkConfig", null);
|
|
918
919
|
__decorate([trace({ quiet: true })], ConfigGitSubProvider.prototype, "getGkConfigRegex", null);
|
|
919
920
|
__decorate([debug()], ConfigGitSubProvider.prototype, "setGkConfig", null);
|