huskies: merge 1176 bug base_branch fallback hardcodes master instead of auto-detecting

This commit is contained in:
Huskies Agent
2026-07-16 16:22:46 +00:00
parent a4e2d4bc25
commit efd0097f76
11 changed files with 301 additions and 50 deletions
@@ -178,6 +178,79 @@ async fn squash_merge_clean_merge_succeeds() {
);
}
#[tokio::test]
async fn squash_merge_succeeds_on_main_based_repo_with_base_branch_unset() {
use std::fs;
use tempfile::tempdir;
let tmp = tempdir().unwrap();
let repo = tmp.path();
// Repo whose default branch is `main` — no `master` branch exists at all,
// and no `.huskies/project.toml` sets `base_branch`. run_squash_merge must
// auto-detect `main` instead of assuming `master` (bug 1176).
Command::new("git")
.args(["init", "-b", "main"])
.current_dir(repo)
.output()
.unwrap();
Command::new("git")
.args(["config", "user.email", "test@test.com"])
.current_dir(repo)
.output()
.unwrap();
Command::new("git")
.args(["config", "user.name", "Test"])
.current_dir(repo)
.output()
.unwrap();
Command::new("git")
.args(["commit", "--allow-empty", "-m", "init"])
.current_dir(repo)
.output()
.unwrap();
Command::new("git")
.args(["checkout", "-b", "feature/story-main_test"])
.current_dir(repo)
.output()
.unwrap();
fs::write(repo.join("new_file.txt"), "new content").unwrap();
Command::new("git")
.args(["add", "."])
.current_dir(repo)
.output()
.unwrap();
Command::new("git")
.args(["commit", "-m", "add new file"])
.current_dir(repo)
.output()
.unwrap();
Command::new("git")
.args(["checkout", "main"])
.current_dir(repo)
.output()
.unwrap();
let result = run_squash_merge(repo, "feature/story-main_test", "main_test").unwrap();
assert!(
matches!(
result,
super::MergeResult::Success {
conflicts_resolved: false,
..
}
),
"clean merge should succeed on a main-based repo; got: {result:?}"
);
assert!(
repo.join("new_file.txt").exists(),
"merged file should exist on main"
);
}
#[tokio::test]
async fn squash_merge_nonexistent_branch_fails() {
use tempfile::tempdir;