Skip to content

Commit 3f4f0da

Browse files
henrikjeclaude
andauthored
fix: remove hardcoded default branch name in integration tests (#9)
* fix: remove hardcoded default branch name in integration tests Two tests hardcoded `main` as the default branch, causing failures in environments where the default is `master`. Replace with branch-agnostic patterns that work regardless of the default branch name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: use explicit default branch in integration test setup Bare repos created with `git init --bare` without `-b main` inherit the system's init.defaultBranch setting, which defaults to `master` in many CI environments. This caused 14 test failures where assertions expected `main` as the default branch name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent daf134a commit 3f4f0da

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

test/arb.bats

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ setup() {
1111
arb init >/dev/null 2>&1
1212

1313
# Create bare origin repos and clone into .arb/repos/
14-
git init --bare "$TEST_DIR/origin/repo-a.git" >/dev/null 2>&1
14+
git init --bare "$TEST_DIR/origin/repo-a.git" -b main >/dev/null 2>&1
1515
git clone "$TEST_DIR/origin/repo-a.git" "$TEST_DIR/project/.arb/repos/repo-a" >/dev/null 2>&1
1616
(cd "$TEST_DIR/project/.arb/repos/repo-a" && git commit --allow-empty -m "init" && git push) >/dev/null 2>&1
1717

18-
git init --bare "$TEST_DIR/origin/repo-b.git" >/dev/null 2>&1
18+
git init --bare "$TEST_DIR/origin/repo-b.git" -b main >/dev/null 2>&1
1919
git clone "$TEST_DIR/origin/repo-b.git" "$TEST_DIR/project/.arb/repos/repo-b" >/dev/null 2>&1
2020
(cd "$TEST_DIR/project/.arb/repos/repo-b" && git commit --allow-empty -m "init" && git push) >/dev/null 2>&1
2121
}
@@ -153,7 +153,7 @@ teardown() {
153153
}
154154

155155
@test "arb clone derives name from URL" {
156-
git init --bare "$TEST_DIR/origin/derived-name.git" >/dev/null 2>&1
156+
git init --bare "$TEST_DIR/origin/derived-name.git" -b main >/dev/null 2>&1
157157
run arb clone "$TEST_DIR/origin/derived-name.git"
158158
[ "$status" -eq 0 ]
159159
[ -d "$TEST_DIR/project/.arb/repos/derived-name/.git" ]
@@ -253,7 +253,7 @@ teardown() {
253253
echo "branch-content" > "$TEST_DIR/project/.arb/repos/repo-a/marker.txt"
254254
git -C "$TEST_DIR/project/.arb/repos/repo-a" add marker.txt >/dev/null 2>&1
255255
git -C "$TEST_DIR/project/.arb/repos/repo-a" commit -m "marker" >/dev/null 2>&1
256-
git -C "$TEST_DIR/project/.arb/repos/repo-a" checkout main >/dev/null 2>&1
256+
git -C "$TEST_DIR/project/.arb/repos/repo-a" checkout - >/dev/null 2>&1
257257

258258
# Create a workspace that reuses the existing branch
259259
arb create reuse-ws --branch reuse-me repo-a
@@ -2873,7 +2873,7 @@ setup_fork_repo() {
28732873
local repo_dir="$TEST_DIR/project/.arb/repos/${name}"
28742874

28752875
# Create upstream bare repo with initial commit
2876-
git init --bare "$upstream_dir" >/dev/null 2>&1
2876+
git init --bare "$upstream_dir" -b main >/dev/null 2>&1
28772877
local tmp_clone="$TEST_DIR/tmp-${name}"
28782878
git clone "$upstream_dir" "$tmp_clone" >/dev/null 2>&1
28792879
(cd "$tmp_clone" && git commit --allow-empty -m "init" && git push) >/dev/null 2>&1
@@ -2896,7 +2896,7 @@ setup_fork_repo() {
28962896
}
28972897

28982898
@test "arb clone --upstream sets up fork layout" {
2899-
git init --bare "$TEST_DIR/upstream/clone-fork.git" >/dev/null 2>&1
2899+
git init --bare "$TEST_DIR/upstream/clone-fork.git" -b main >/dev/null 2>&1
29002900
local tmp_clone="$TEST_DIR/tmp-clone-fork"
29012901
git clone "$TEST_DIR/upstream/clone-fork.git" "$tmp_clone" >/dev/null 2>&1
29022902
(cd "$tmp_clone" && git commit --allow-empty -m "init" && git push) >/dev/null 2>&1
@@ -3047,7 +3047,7 @@ setup_fork_repo() {
30473047
local upstream_dir="$TEST_DIR/upstream/conv-test.git"
30483048
local fork_dir="$TEST_DIR/fork/conv-test.git"
30493049

3050-
git init --bare "$upstream_dir" >/dev/null 2>&1
3050+
git init --bare "$upstream_dir" -b main >/dev/null 2>&1
30513051
local tmp_clone="$TEST_DIR/tmp-conv"
30523052
git clone "$upstream_dir" "$tmp_clone" >/dev/null 2>&1
30533053
(cd "$tmp_clone" && git commit --allow-empty -m "init" && git push) >/dev/null 2>&1
@@ -3072,7 +3072,7 @@ setup_fork_repo() {
30723072
local canonical_dir="$TEST_DIR/upstream/custom-names.git"
30733073
local fork_dir="$TEST_DIR/fork/custom-names.git"
30743074

3075-
git init --bare "$canonical_dir" >/dev/null 2>&1
3075+
git init --bare "$canonical_dir" -b main >/dev/null 2>&1
30763076
local tmp_clone="$TEST_DIR/tmp-custom"
30773077
git clone "$canonical_dir" "$tmp_clone" >/dev/null 2>&1
30783078
(cd "$tmp_clone" && git commit --allow-empty -m "init" && git push) >/dev/null 2>&1
@@ -3132,7 +3132,7 @@ setup_fork_repo() {
31323132
local bare_b="$TEST_DIR/fork/ambig.git"
31333133
local bare_c="$TEST_DIR/staging/ambig.git"
31343134

3135-
git init --bare "$bare_a" >/dev/null 2>&1
3135+
git init --bare "$bare_a" -b main >/dev/null 2>&1
31363136
local tmp_clone="$TEST_DIR/tmp-ambig"
31373137
git clone "$bare_a" "$tmp_clone" >/dev/null 2>&1
31383138
(cd "$tmp_clone" && git commit --allow-empty -m "init" && git push) >/dev/null 2>&1
@@ -3188,7 +3188,7 @@ setup_fork_repo() {
31883188
local upstream_b="$TEST_DIR/upstream/repo-b-fork.git"
31893189
local fork_b="$TEST_DIR/fork/repo-b-fork.git"
31903190

3191-
git init --bare "$upstream_b" >/dev/null 2>&1
3191+
git init --bare "$upstream_b" -b main >/dev/null 2>&1
31923192
local tmp_clone="$TEST_DIR/tmp-repo-b-fork"
31933193
git clone "$upstream_b" "$tmp_clone" >/dev/null 2>&1
31943194
(cd "$tmp_clone" && echo "upstream content" > file.txt && git add file.txt && git commit -m "upstream init" && git push) >/dev/null 2>&1
@@ -3217,7 +3217,7 @@ setup_fork_repo() {
32173217
}
32183218

32193219
@test "fork: clone --upstream fails gracefully with bad upstream URL" {
3220-
git init --bare "$TEST_DIR/fork/bad-upstream.git" >/dev/null 2>&1
3220+
git init --bare "$TEST_DIR/fork/bad-upstream.git" -b main >/dev/null 2>&1
32213221
local tmp_clone="$TEST_DIR/tmp-bad-upstream"
32223222
git clone "$TEST_DIR/fork/bad-upstream.git" "$tmp_clone" >/dev/null 2>&1
32233223
(cd "$tmp_clone" && git commit --allow-empty -m "init" && git push) >/dev/null 2>&1
@@ -3397,13 +3397,7 @@ push_then_delete_remote() {
33973397
git -C "$TEST_DIR/project/ws-behind/repo-a" push -u origin ws-behind >/dev/null 2>&1
33983398

33993399
# Advance the remote's default branch so ws-behind is behind base
3400-
git -C "$TEST_DIR/remotes/repo-a.git" checkout -b temp-advance >/dev/null 2>&1 || true
3401-
git -C "$TEST_DIR/project/.arb/repos/repo-a" checkout main >/dev/null 2>&1
3402-
echo "advance" > "$TEST_DIR/project/.arb/repos/repo-a/advance.txt"
3403-
git -C "$TEST_DIR/project/.arb/repos/repo-a" add advance.txt
3404-
git -C "$TEST_DIR/project/.arb/repos/repo-a" commit -m "advance main" >/dev/null 2>&1
3405-
git -C "$TEST_DIR/project/.arb/repos/repo-a" push origin main >/dev/null 2>&1
3406-
git -C "$TEST_DIR/project/.arb/repos/repo-a" checkout --detach >/dev/null 2>&1
3400+
(cd "$TEST_DIR/project/.arb/repos/repo-a" && echo "advance" > advance.txt && git add advance.txt && git commit -m "advance main" && git push) >/dev/null 2>&1
34073401

34083402
# Fetch so the workspace sees the new remote state
34093403
git -C "$TEST_DIR/project/ws-behind/repo-a" fetch origin >/dev/null 2>&1

0 commit comments

Comments
 (0)