Skip to content

Commit 1e0057e

Browse files
committed
fix(server): a path worded like a missing-ref diagnostic is not reported as one
1 parent 168c4f4 commit 1e0057e

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

‎apps/server/src/vcs/GitVcsDriverCore.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,6 +1333,10 @@ it.layer(layerTest)("GitVcsDriver core integration", (it) => {
13331333
// Git cannot tell a missing revision from a missing file in these.
13341334
{ label: "an argument that may be a path", args: ["log", "-1", "missing"] },
13351335
{ label: "a pathspec", args: ["checkout", "missing"] },
1336+
{
1337+
label: "a pathspec worded like a diagnostic",
1338+
args: ["checkout", "HEAD", "--", "fatal: invalid reference: missing"],
1339+
},
13361340
// The tag exists; it names a tree, which git reports in the same words.
13371341
{ label: "a worktree from a non-commit", args: ["worktree", "add", "../tree", "tree-tag"] },
13381342
{ label: "a non-commit revision", args: ["rev-parse", "--verify", "tree-tag^{commit}"] },

‎apps/server/src/vcs/GitVcsDriverCore.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,10 @@ const GIT_FAILURE_REASON_PATTERNS: ReadonlyArray<readonly [RegExp, GitCommandFai
454454
[/fatal: '[^']+' already exists|destination path .+ already exists/i, "path_already_exists"],
455455
// Wordings git uses for a ref or revision that does not resolve. `unknown
456456
// revision or path not in the working tree` and `pathspec ... did not match`
457-
// are left out: they also cover a missing file.
457+
// are left out: they also cover a missing file. Anchored because a quoted
458+
// path in another diagnostic can contain these words.
458459
[
459-
/fatal: (?:invalid reference: |not a valid object name|needed a single revision|bad revision |'.+' is not a commit and a branch '.+' cannot be created from it)/i,
460+
/^fatal: (?:invalid reference: |not a valid object name|needed a single revision|bad revision |'.+' is not a commit and a branch '.+' cannot be created from it)/im,
460461
"ref_not_found",
461462
],
462463
];

0 commit comments

Comments
 (0)