Skip to content

Commit 5a3d86b

Browse files
committed
Adds more logging
1 parent 542c8b0 commit 5a3d86b

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

src/env/node/git/sub-providers/status.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { splitPath } from '../../../../system/-webview/path';
2727
import { gate } from '../../../../system/decorators/-webview/gate';
2828
import { log } from '../../../../system/decorators/log';
2929
import { Logger } from '../../../../system/logger';
30+
import { getLogScope, setLogScopeExit } from '../../../../system/logger.scope';
3031
import { getSettledValue } from '../../../../system/promise';
3132
import type { Git } from '../git';
3233
import { GitErrors } from '../git';
@@ -47,6 +48,8 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
4748
@gate()
4849
@log()
4950
async getPausedOperationStatus(repoPath: string): Promise<GitPausedOperationStatus | undefined> {
51+
const scope = getLogScope();
52+
5053
let status = this.cache.pausedOperationStatus?.get(repoPath);
5154
if (status == null) {
5255
async function getCore(this: StatusGitSubProvider): Promise<GitPausedOperationStatus | undefined> {
@@ -97,10 +100,12 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
97100

98101
if (!operations.size) return undefined;
99102

100-
const operation = [...operations].sort(
103+
const sortedOperations = [...operations].sort(
101104
(a, b) => orderedOperations.indexOf(a) - orderedOperations.indexOf(b),
102-
)[0];
105+
);
106+
Logger.log(`Detected paused operations: ${sortedOperations.join(', ')}`);
103107

108+
const operation = sortedOperations[0];
104109
switch (operation) {
105110
case 'cherry-pick': {
106111
const cherryPickHead = (
@@ -112,7 +117,10 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
112117
'CHERRY_PICK_HEAD',
113118
)
114119
)?.trim();
115-
if (!cherryPickHead) return undefined;
120+
if (!cherryPickHead) {
121+
setLogScopeExit(scope, 'No CHERRY_PICK_HEAD found');
122+
return undefined;
123+
}
116124

117125
const current = (await this.provider.branches.getCurrentBranchReference(repoPath))!;
118126

@@ -135,7 +143,10 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
135143
'MERGE_HEAD',
136144
)
137145
)?.trim();
138-
if (!mergeHead) return undefined;
146+
if (!mergeHead) {
147+
setLogScopeExit(scope, 'No MERGE_HEAD found');
148+
return undefined;
149+
}
139150

140151
const [branchResult, mergeBaseResult, possibleSourceBranchesResult] = await Promise.allSettled([
141152
this.provider.branches.getCurrentBranchReference(repoPath),
@@ -176,7 +187,10 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
176187
'REVERT_HEAD',
177188
)
178189
)?.trim();
179-
if (!revertHead) return undefined;
190+
if (!revertHead) {
191+
setLogScopeExit(scope, 'No REVERT_HEAD found');
192+
return undefined;
193+
}
180194

181195
const current = (await this.provider.branches.getCurrentBranchReference(repoPath))!;
182196

@@ -191,7 +205,10 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
191205
case 'rebase-apply':
192206
case 'rebase-merge': {
193207
let branch = await this.git.readDotGitFile(gitDir, [operation, 'head-name']);
194-
if (!branch) return undefined;
208+
if (!branch) {
209+
setLogScopeExit(scope, `No '${operation}/head-name' found`);
210+
return undefined;
211+
}
195212

196213
const [
197214
rebaseHeadResult,
@@ -219,7 +236,10 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
219236

220237
const origHead = getSettledValue(origHeadResult);
221238
const onto = getSettledValue(ontoResult);
222-
if (origHead == null || onto == null) return undefined;
239+
if (origHead == null || onto == null) {
240+
setLogScopeExit(scope, `Neither '${operation}/orig-head' nor '${operation}/onto' found`);
241+
return undefined;
242+
}
223243

224244
const rebaseHead = getSettledValue(rebaseHeadResult)?.trim();
225245

0 commit comments

Comments
 (0)