Skip to content

Commit 7c4d174

Browse files
committed
Adds more logging
Refs: #3026
1 parent 8d2c39a commit 7c4d174

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/env/node/git/localGitProvider.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
15721572
protected readonly unsafePaths = new Set<string>();
15731573

15741574
@gate()
1575-
@debug()
1575+
@debug({ exit: true })
15761576
async findRepositoryUri(uri: Uri, isDirectory?: boolean): Promise<Uri | undefined> {
15771577
const scope = getLogScope();
15781578

@@ -2250,7 +2250,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
22502250
return filterMap(data.split('\n'), b => b.trim() || undefined);
22512251
}
22522252

2253-
@log()
2253+
@log({ exit: true })
22542254
getCommitCount(repoPath: string, ref: string): Promise<number | undefined> {
22552255
return this.git.rev_list__count(repoPath, ref);
22562256
}
@@ -2974,7 +2974,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
29742974
}
29752975
}
29762976

2977-
@log()
2977+
@log({ exit: true })
29782978
async getDefaultBranchName(repoPath: string | undefined, remote?: string): Promise<string | undefined> {
29792979
if (repoPath == null) return undefined;
29802980

@@ -3302,14 +3302,16 @@ export class LocalGitProvider implements GitProvider, Disposable {
33023302
return files[0];
33033303
}
33043304

3305-
@log()
3305+
@log({ exit: true })
33063306
async getFirstCommitSha(repoPath: string): Promise<string | undefined> {
33073307
const data = await this.git.rev_list(repoPath, 'HEAD', { maxParents: 0 });
33083308
return data?.[0];
33093309
}
33103310

33113311
@gate()
3312-
@debug()
3312+
@debug<LocalGitProvider['getGitDir']>({
3313+
exit: r => `returned ${r.uri.toString(true)}, commonUri=${r.commonUri?.toString(true)}`,
3314+
})
33133315
async getGitDir(repoPath: string): Promise<GitDir> {
33143316
const repo = this._repoInfoCache.get(repoPath);
33153317
if (repo?.gitDir != null) return repo.gitDir;
@@ -5727,7 +5729,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
57275729
}
57285730
}
57295731

5730-
@log()
5732+
@log({ exit: true })
57315733
async getScmRepository(repoPath: string): Promise<ScmRepository | undefined> {
57325734
const scope = getLogScope();
57335735
try {
@@ -5739,19 +5741,20 @@ export class LocalGitProvider implements GitProvider, Disposable {
57395741
}
57405742
}
57415743

5742-
@log()
5744+
@log({ exit: true })
57435745
async getOrOpenScmRepository(repoPath: string | Uri): Promise<ScmRepository | undefined> {
57445746
const scope = getLogScope();
57455747
try {
57465748
const uri = repoPath instanceof Uri ? repoPath : Uri.file(repoPath);
57475749
const gitApi = await this.getScmGitApi();
5750+
if (gitApi == null) return undefined;
57485751

5749-
let repo = gitApi?.getRepository(uri) ?? undefined;
5750-
if (repo == null && gitApi?.openRepository != null) {
5751-
repo = (await gitApi?.openRepository?.(uri)) ?? undefined;
5752+
let repo = gitApi.getRepository(uri);
5753+
if (repo == null) {
5754+
Logger.debug(scope, '\u2022 no existing repository found, opening repository...');
5755+
repo ??= await gitApi.openRepository?.(uri);
57525756
}
5753-
5754-
return repo;
5757+
return repo ?? undefined;
57555758
} catch (ex) {
57565759
Logger.error(ex, scope);
57575760
return undefined;

src/extension.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export async function activate(context: ExtensionContext): Promise<GitLensApi |
6868

6969
if (isRepository(o) || isBranch(o) || isCommit(o) || isTag(o) || isViewNode(o)) return o.toString();
7070

71+
if ('rootUri' in o && o.rootUri instanceof Uri) {
72+
return `ScmRepository(rootUri=${o.rootUri.toString(true)})`;
73+
}
74+
7175
if ('uri' in o && o.uri instanceof Uri) {
7276
return `${
7377
'name' in o && 'index' in o ? 'WorkspaceFolder' : getLoggableName(o)

src/git/gitProviderService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ export class GitProviderService implements Disposable {
574574

575575
setLogScopeExit(
576576
scope,
577-
` ${GlyphChars.Dot} workspaceFolders=${workspaceFolders?.length}, git.autoRepositoryDetection=${autoRepositoryDetection}`,
577+
` ${GlyphChars.Dot} repositories=${this.repositoryCount}, workspaceFolders=${workspaceFolders?.length}, git.autoRepositoryDetection=${autoRepositoryDetection}`,
578578
);
579579
}
580580

0 commit comments

Comments
 (0)