Skip to content

Commit c85804d

Browse files
anandgupta42claude
andcommitted
fix: make detectGit test resilient to CI detached HEAD
GitHub Actions checks out in detached HEAD state, so git branch --show-current returns empty. The test now accepts undefined branch in that case. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f11614f commit c85804d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

packages/altimate-code/test/tool/project-scan.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ describe("detectGit", () => {
4848
expect(typeof result.branch).toBe("string")
4949
})
5050

51-
test("returns a branch name", async () => {
51+
test("returns a branch name or undefined in detached HEAD", async () => {
5252
const result = await detectGit()
53-
// We are in a real git repo (altimate-code), so branch should be defined
54-
expect(result.branch).toBeDefined()
55-
expect(result.branch!.length).toBeGreaterThan(0)
53+
// In CI, GitHub Actions checks out in detached HEAD, so branch may be undefined
54+
if (result.branch !== undefined) {
55+
expect(result.branch.length).toBeGreaterThan(0)
56+
}
5657
})
5758

5859
test("returns a remote URL when origin exists", async () => {

0 commit comments

Comments
 (0)