Skip to content

Commit 05f70b8

Browse files
committed
Fixes Git error not returning props when ignoring
Avoids logging expected patch failure during merged detection
1 parent e2c6a60 commit 05f70b8

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/env/node/git/git.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,19 @@ export class Git {
326326
};
327327
} catch (ex) {
328328
if (errorHandling === GitErrorHandling.Ignore) {
329+
if (ex instanceof RunError) {
330+
return {
331+
stdout: ex.stdout as T,
332+
stderr: ex.stderr as T | undefined,
333+
exitCode: ex.code != null ? (typeof ex.code === 'number' ? ex.code : parseInt(ex.code, 10)) : 0,
334+
cancelled: ex instanceof CancelledRunError,
335+
};
336+
}
337+
329338
return {
330339
stdout: '' as T,
331-
stderr: result?.stderr as T | undefined,
332-
exitCode: result?.exitCode ?? 0,
340+
stderr: undefined,
341+
exitCode: 0,
333342
cancelled: ex instanceof CancelledRunError,
334343
};
335344
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,14 +534,21 @@ export class BranchesGitSubProvider implements GitBranchesSubProvider {
534534
const { env } = disposableIndex;
535535

536536
result = await this.git.exec(
537-
{ cwd: repoPath, cancellation: cancellation, env: env, stdin: result.stdout },
537+
{
538+
cwd: repoPath,
539+
cancellation: cancellation,
540+
env: env,
541+
errors: GitErrorHandling.Ignore,
542+
stdin: result.stdout,
543+
},
538544
'apply',
539545
'--cached',
540546
'--reverse',
541547
'--check',
542548
'-',
543549
);
544-
if (!result.stdout.trim()) {
550+
551+
if (result.exitCode === 0 && !result.stdout.trim() && !result.stderr?.trim()) {
545552
return { merged: true, confidence: 'medium' };
546553
}
547554
}

0 commit comments

Comments
 (0)