Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Simplify git config setup: include user identity in gitconfig file

Maximilian Roosfe6f424091e1
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 4cc24c02f..cda4b112f 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -165,11 +165,14 @@ impl TestRepo {
// Create isolated config path for this test
let test_config_path = temp_dir.path().join("test-config.toml");
- // Create git config file with test settings
+ // Create git config file with test settings including user identity
+ // This eliminates the need for separate `git config user.name/email` commands
let git_config_path = temp_dir.path().join("test-gitconfig");
std::fs::write(
&git_config_path,
- "[advice]\n\tmergeConflict = false\n\tresolveConflict = false\n",
+ "[user]\n\tname = Test User\n\temail = [email protected]\n\
+ [advice]\n\tmergeConflict = false\n\tresolveConflict = false\n\
+ [init]\n\tdefaultBranch = main\n",
)
.unwrap();
@@ -184,27 +187,10 @@ impl TestRepo {
};
// Initialize git repo with isolated environment
+ // User config is already in the gitconfig file, no separate config commands needed
let mut cmd = Command::new("git");
repo.configure_git_cmd(&mut cmd);
- cmd.args(["init", "-b", "main"])
- .current_dir(&repo.root)
- .output()
- .unwrap();
-
- // Configure git user
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["config", "user.name", "Test User"])
- .current_dir(&repo.root)
- .output()
- .unwrap();
-
- let mut cmd = Command::new("git");
- repo.configure_git_cmd(&mut cmd);
- cmd.args(["config", "user.email", "[email protected]"])
- .current_dir(&repo.root)
- .output()
- .unwrap();
+ cmd.args(["init"]).current_dir(&repo.root).output().unwrap();
repo
}
diff --git a/tests/integration_tests/config_var.rs b/tests/integration_tests/config_var.rs
index 12fcd9fe2..e2c8c4a82 100644
--- a/tests/integration_tests/config_var.rs
+++ b/tests/integration_tests/config_var.rs
@@ -202,9 +202,8 @@ fn test_var_get_marker_specific_branch() {
#[test]
fn test_var_get_default_branch() {
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
let output = wt_var_get_cmd(&repo, &["default-branch"]).output().unwrap();
assert!(output.status.success());
diff --git a/tests/integration_tests/directives.rs b/tests/integration_tests/directives.rs
index ed295c84f..a6257e29b 100644
--- a/tests/integration_tests/directives.rs
+++ b/tests/integration_tests/directives.rs
@@ -125,7 +125,6 @@ fn test_remove_without_internal() {
fn test_merge_internal_no_remove() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -177,7 +176,6 @@ fn test_merge_internal_no_remove() {
fn test_merge_internal_remove() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
diff --git a/tests/integration_tests/e2e_shell.rs b/tests/integration_tests/e2e_shell.rs
index 8c763a73e..d094ff8d1 100644
--- a/tests/integration_tests/e2e_shell.rs
+++ b/tests/integration_tests/e2e_shell.rs
@@ -28,7 +28,6 @@ fn test_shell_integration_switch_and_remove(#[case] shell: &str) {
skip_if_shell_unavailable!(shell);
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
let init_code = generate_init_code(&repo, shell);
let bin_path = wt_bin_dir();
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index 07cc0cca9..b60bbda80 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -40,12 +40,14 @@ fn snapshot_merge_with_env(
});
}
-/// Standard merge test setup: creates repo with remote, main worktree, and feature worktree with one commit.
+/// Standard merge test setup: creates repo with main worktree and feature worktree with one commit.
/// Returns (repo, feature_wt_path).
+///
+/// Note: No remote is set up - merge works with local branches only. Tests that
+/// specifically need remote behavior should call `repo.setup_remote()` explicitly.
fn setup_merge_scenario() -> (TestRepo, std::path::PathBuf) {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -82,7 +84,6 @@ fn setup_merge_scenario() -> (TestRepo, std::path::PathBuf) {
fn setup_merge_scenario_multi_commit() -> (TestRepo, std::path::PathBuf) {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -139,7 +140,6 @@ fn test_merge_fast_forward() {
fn test_merge_when_primary_not_on_default_but_default_has_worktree() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Move the primary worktree off main
repo.switch_primary_to("develop");
@@ -188,9 +188,8 @@ fn test_merge_with_no_remove_flag() {
#[test]
fn test_merge_already_on_target() {
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Already on main branch (repo root)
snapshot_merge("merge_already_on_target", &repo, &[], None);
@@ -200,7 +199,6 @@ fn test_merge_already_on_target() {
fn test_merge_dirty_working_tree() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a feature worktree with uncommitted changes
let feature_wt = repo.add_worktree("feature");
@@ -219,7 +217,6 @@ fn test_merge_dirty_working_tree() {
fn test_merge_not_fast_forward() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create commits in both branches
// Add commit to main (repo root)
@@ -271,9 +268,8 @@ fn test_merge_not_fast_forward() {
/// The hint should say "Run 'wt merge' again" (not "Use 'wt merge'").
#[test]
fn test_merge_no_commit_not_fast_forward() {
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Get the initial commit SHA to create feature branch from there
let mut cmd = Command::new("git");
@@ -349,7 +345,7 @@ fn test_merge_no_commit_not_fast_forward() {
#[test]
fn test_merge_rebase_conflict() {
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
// Create a shared file
std::fs::write(repo.root_path().join("shared.txt"), "initial content\n").unwrap();
@@ -362,7 +358,6 @@ fn test_merge_rebase_conflict() {
.unwrap();
repo.commit("Add shared file");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -474,7 +469,6 @@ fn test_merge_error_detached_head() {
fn test_merge_squash_deterministic() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -543,7 +537,6 @@ fn test_merge_squash_deterministic() {
fn test_merge_squash_with_llm() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -602,7 +595,6 @@ args = ["-c", "cat >/dev/null && echo 'feat: implement user authentication syste
fn test_merge_squash_llm_command_not_found() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -662,7 +654,6 @@ fn test_merge_squash_llm_error() {
// Test that LLM command errors show proper gutter formatting with full command
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -729,7 +720,6 @@ args = ["-c", "cat > /dev/null; echo 'Error: connection refused' >&2 && exit 1"]
fn test_merge_squash_single_commit() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -783,7 +773,6 @@ fn test_merge_no_squash() {
fn test_merge_squash_empty_changes() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -859,7 +848,6 @@ fn test_merge_squash_empty_changes() {
fn test_merge_auto_commit_deterministic() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -904,7 +892,6 @@ fn test_merge_auto_commit_deterministic() {
fn test_merge_auto_commit_with_llm() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -983,7 +970,6 @@ args = ["-c", "cat >/dev/null && echo 'fix: update file 1 content'"]
fn test_merge_with_untracked_files() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -1031,7 +1017,6 @@ fn test_merge_with_untracked_files() {
fn test_merge_pre_merge_command_success() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with pre-merge command
let config_dir = repo.root_path().join(".config");
@@ -1080,7 +1065,6 @@ fn test_merge_pre_merge_command_success() {
fn test_merge_pre_merge_command_failure() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with failing pre-merge command
let config_dir = repo.root_path().join(".config");
@@ -1129,7 +1113,6 @@ fn test_merge_pre_merge_command_failure() {
fn test_merge_pre_merge_command_no_hooks() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with failing pre-merge command
let config_dir = repo.root_path().join(".config");
@@ -1178,7 +1161,6 @@ fn test_merge_pre_merge_command_no_hooks() {
fn test_merge_pre_merge_command_named() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with named pre-merge commands
let config_dir = repo.root_path().join(".config");
@@ -1236,7 +1218,6 @@ test = "exit 0"
fn test_merge_post_merge_command_success() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with post-merge command that writes a marker file
let config_dir = repo.root_path().join(".config");
@@ -1302,7 +1283,6 @@ fn test_merge_post_merge_command_success() {
fn test_merge_post_merge_command_skipped_with_no_verify() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with post-merge command that writes a marker file
let config_dir = repo.root_path().join(".config");
@@ -1362,7 +1342,6 @@ fn test_merge_post_merge_command_skipped_with_no_verify() {
fn test_merge_post_merge_command_failure() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with failing post-merge command
let config_dir = repo.root_path().join(".config");
@@ -1411,7 +1390,6 @@ fn test_merge_post_merge_command_failure() {
fn test_merge_post_merge_command_named() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with named post-merge commands
let config_dir = repo.root_path().join(".config");
@@ -1481,7 +1459,6 @@ fn test_merge_post_merge_runs_with_nothing_to_merge() {
// Verify post-merge hooks run even when there's nothing to merge
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with post-merge command
let config_dir = repo.root_path().join(".config");
@@ -1525,9 +1502,8 @@ fn test_merge_post_merge_runs_with_nothing_to_merge() {
#[test]
fn test_merge_post_merge_runs_from_main_branch() {
// Verify post-merge hooks run when merging from main to main (nothing to do)
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with post-merge command
let config_dir = repo.root_path().join(".config");
@@ -1560,7 +1536,6 @@ fn test_merge_post_merge_runs_from_main_branch() {
fn test_merge_pre_commit_command_success() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with pre-commit command
let config_dir = repo.root_path().join(".config");
@@ -1599,7 +1574,6 @@ fn test_merge_pre_commit_command_success() {
fn test_merge_pre_commit_command_failure() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with failing pre-commit command
let config_dir = repo.root_path().join(".config");
@@ -1634,7 +1608,6 @@ fn test_merge_pre_commit_command_failure() {
fn test_merge_pre_squash_command_success() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with pre-commit command (used for both squash and no-squash)
let config_dir = repo.root_path().join(".config");
@@ -1687,7 +1660,6 @@ fn test_merge_pre_squash_command_success() {
fn test_merge_pre_squash_command_failure() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with failing pre-commit command (used for both squash and no-squash)
let config_dir = repo.root_path().join(".config");
@@ -1773,9 +1745,8 @@ fn test_merge_no_remote() {
/// Switch output: tests/snapshots/integration__integration_tests__merge__readme_example_simple_switch.snap
#[test]
fn test_readme_example_simple() {
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Snapshot the switch --create command (runs from bare repo)
snapshot_switch(
@@ -1831,7 +1802,6 @@ pub fn refresh(refresh_token: &str) -> String {
fn test_readme_example_complex() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with multiple hooks
let config_dir = repo.root_path().join(".config");
@@ -2066,9 +2036,8 @@ command = "{}"
/// Source: tests/snapshots/integration__integration_tests__merge__readme_example_hooks_post_create.snap
#[test]
fn test_readme_example_hooks_post_create() {
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with post-create and post-start hooks
let config_dir = repo.root_path().join(".config");
@@ -2154,7 +2123,6 @@ fi
fn test_readme_example_hooks_pre_merge() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with pre-merge hooks
let config_dir = repo.root_path().join(".config");
@@ -2410,7 +2378,6 @@ command = "{}"
fn test_merge_no_commit_with_clean_tree() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -2468,7 +2435,6 @@ fn test_merge_no_commit_with_clean_tree() {
fn test_merge_no_commit_with_dirty_tree() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a feature worktree with a commit
let feature_wt = repo.add_worktree("feature");
@@ -2513,7 +2479,6 @@ fn test_merge_no_commit_with_dirty_tree() {
fn test_merge_no_commit_no_squash_no_remove_redundant() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -2571,7 +2536,6 @@ fn test_merge_no_commit_no_squash_no_remove_redundant() {
fn test_merge_no_commits() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
repo.add_main_worktree();
@@ -2587,7 +2551,6 @@ fn test_merge_no_commits() {
fn test_merge_no_commits_with_changes() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
repo.add_main_worktree();
@@ -2611,7 +2574,6 @@ fn test_merge_rebase_fast_forward() {
// Should show "Fast-forwarded to main" without progress message
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a feature worktree with NO commits (just branched from main)
let feature_wt = repo.add_worktree("fast-forward-test");
@@ -2648,7 +2610,6 @@ fn test_merge_rebase_true_rebase() {
// Should show "Rebasing onto main..." progress message
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a feature worktree with a commit
let feature_wt = repo.add_worktree("true-rebase-test");
@@ -2698,7 +2659,6 @@ fn test_merge_rebase_true_rebase() {
fn test_merge_primary_on_different_branch() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
repo.switch_primary_to("develop");
assert_eq!(repo.current_branch(), "develop");
@@ -2736,7 +2696,6 @@ fn test_merge_primary_on_different_branch() {
fn test_merge_primary_on_different_branch_dirty() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Make main and develop diverge - modify file.txt on main
fs::write(repo.root_path().join("file.txt"), "main version").unwrap();
@@ -2807,7 +2766,6 @@ fn test_merge_primary_on_different_branch_dirty() {
fn test_merge_race_condition_commit_after_push() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -2913,9 +2871,8 @@ fn test_merge_race_condition_commit_after_push() {
#[test]
fn test_merge_to_non_default_target() {
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Switch back to main and add a commit there
let mut cmd = Command::new("git");
@@ -3031,7 +2988,6 @@ fn test_merge_to_non_default_target() {
fn test_merge_squash_with_working_tree_creates_backup() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
repo.add_main_worktree();
@@ -3198,7 +3154,6 @@ fn snapshot_step_commit_with_env(
fn test_step_squash_with_no_verify_flag() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a feature worktree with multiple commits
let feature_wt = repo.add_worktree("feature");
@@ -3260,7 +3215,6 @@ fn test_step_squash_with_no_verify_flag() {
fn test_step_squash_with_stage_tracked_flag() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
let feature_wt = repo.add_worktree("feature");
@@ -3314,7 +3268,6 @@ fn test_step_squash_with_stage_tracked_flag() {
fn test_step_squash_with_both_flags() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
let feature_wt = repo.add_worktree("feature");
@@ -3378,7 +3331,6 @@ fn test_step_squash_no_commits() {
// Test "nothing to squash; no commits ahead" message
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a feature worktree but don't add any commits
let feature_wt = repo.add_worktree("feature");
@@ -3391,7 +3343,6 @@ fn test_step_squash_single_commit() {
// Test "nothing to squash; already a single commit" message
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a feature worktree with exactly one commit
let feature_wt = repo.add_worktree("feature");
@@ -3536,7 +3487,6 @@ fn test_merge_error_uncommitted_changes_with_no_commit() {
// Tests the `uncommitted_changes()` error function when using --no-commit with dirty tree
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -3568,7 +3518,6 @@ fn test_merge_error_conflicting_changes_in_target() {
// uncommitted changes that overlap with files being pushed
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Switch primary worktree off main so we can create a worktree for main
repo.switch_primary_to("develop");
diff --git a/tests/integration_tests/push.rs b/tests/integration_tests/push.rs
index 01d8e87e6..b2149f69c 100644
--- a/tests/integration_tests/push.rs
+++ b/tests/integration_tests/push.rs
@@ -18,7 +18,6 @@ fn snapshot_push(test_name: &str, repo: &TestRepo, args: &[&str], cwd: Option<&s
fn test_push_fast_forward() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create a worktree for main (checking out existing branch)
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
@@ -55,7 +54,6 @@ fn test_push_fast_forward() {
fn test_push_not_fast_forward() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create commits in both worktrees
// The repo root is already the main worktree
@@ -100,7 +98,6 @@ fn test_push_not_fast_forward() {
fn test_push_to_default_branch() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
let main_wt = repo.root_path().parent().unwrap().join("repo.main-wt");
let mut cmd = Command::new("git");
@@ -135,7 +132,6 @@ fn test_push_to_default_branch() {
fn test_push_with_dirty_target() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Make main worktree (repo root) dirty with a conflicting file
std::fs::write(repo.root_path().join("conflict.txt"), "old content").unwrap();
@@ -187,7 +183,6 @@ fn test_push_with_dirty_target() {
fn test_push_dirty_target_autostash() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Make main worktree (repo root) dirty with a non-conflicting file
std::fs::write(repo.root_path().join("notes.txt"), "temporary notes").unwrap();
@@ -240,7 +235,6 @@ fn test_push_dirty_target_autostash() {
fn test_push_error_not_fast_forward() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature branch from initial commit
let feature_wt = repo.add_worktree("feature");
@@ -299,7 +293,6 @@ fn test_push_error_not_fast_forward() {
fn test_push_error_with_merge_commits() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature branch
let feature_wt = repo.add_worktree("feature");
@@ -371,7 +364,6 @@ fn test_push_error_with_merge_commits() {
fn test_push_with_merge_commits_allowed() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature branch
let feature_wt = repo.add_worktree("feature");
diff --git a/tests/integration_tests/remove.rs b/tests/integration_tests/remove.rs
index f1975e1f0..de952465c 100644
--- a/tests/integration_tests/remove.rs
+++ b/tests/integration_tests/remove.rs
@@ -30,9 +30,8 @@ fn snapshot_remove_with_global_flags(
/// Common setup for remove tests - creates repo with initial commit and remote
fn setup_remove_repo() -> TestRepo {
- let mut repo = TestRepo::new();
+ let repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
repo
}
@@ -147,7 +146,8 @@ fn test_remove_nonexistent_worktree() {
#[test]
fn test_remove_remote_only_branch() {
- let repo = setup_remove_repo();
+ let mut repo = setup_remove_repo();
+ repo.setup_remote("main"); // This test specifically needs a remote
// Create a remote-only branch by pushing a branch then deleting it locally
Command::new("git")
diff --git a/tests/integration_tests/shell_wrapper.rs b/tests/integration_tests/shell_wrapper.rs
index f3cba34d4..734e1666d 100644
--- a/tests/integration_tests/shell_wrapper.rs
+++ b/tests/integration_tests/shell_wrapper.rs
@@ -958,7 +958,6 @@ approved-commands = [
skip_if_shell_unavailable!(shell);
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with pre-merge validation
let config_dir = repo.root_path().join(".config");
@@ -1041,7 +1040,6 @@ approved-commands = [
skip_if_shell_unavailable!(shell);
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with failing pre-merge validation
let config_dir = repo.root_path().join(".config");
@@ -1122,7 +1120,6 @@ approved-commands = [
skip_if_shell_unavailable!(shell);
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Copy the fixture script to the test repo to avoid path issues with special characters
// (CARGO_MANIFEST_DIR may contain single quotes like worktrunk.'∅' which break shell parsing)
@@ -1329,7 +1326,6 @@ approved-commands = ["echo 'test command executed'"]
fn test_readme_example_simple_switch() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create worktree through shell wrapper (suppresses hint)
let output = exec_through_wrapper("bash", &repo, "switch", &["--create", "fix-auth"]);
@@ -1346,7 +1342,6 @@ approved-commands = ["echo 'test command executed'"]
fn test_readme_example_switch_back() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create worktrees (fix-auth is where we are after step 2, feature-api exists from earlier)
exec_through_wrapper("bash", &repo, "switch", &["--create", "fix-auth"]);
@@ -1370,7 +1365,6 @@ approved-commands = ["echo 'test command executed'"]
fn test_readme_example_remove() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create worktrees
exec_through_wrapper("bash", &repo, "switch", &["--create", "fix-auth"]);
@@ -2200,7 +2194,6 @@ approved-commands = ["echo 'cleanup test'"]
fn test_readme_example_hooks_pre_merge() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with pre-merge hooks
let config_dir = repo.root_path().join(".config");
@@ -2472,7 +2465,6 @@ command = "{}"
fn test_readme_example_hooks_post_create() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create project config with post-create and post-start hooks
let config_dir = repo.root_path().join(".config");
diff --git a/tests/integration_tests/statusline.rs b/tests/integration_tests/statusline.rs
index a291cc456..a58a551d7 100644
--- a/tests/integration_tests/statusline.rs
+++ b/tests/integration_tests/statusline.rs
@@ -77,7 +77,6 @@ fn setup_repo_with_changes() -> TestRepo {
fn setup_repo_with_commits_ahead() -> TestRepo {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature branch with commits ahead
let feature_path = repo.add_worktree("feature");
diff --git a/tests/integration_tests/user_hooks.rs b/tests/integration_tests/user_hooks.rs
index 5c1e66a95..c229cc4a7 100644
--- a/tests/integration_tests/user_hooks.rs
+++ b/tests/integration_tests/user_hooks.rs
@@ -274,7 +274,6 @@ fn snapshot_merge(test_name: &str, repo: &TestRepo, args: &[&str], cwd: Option<&
fn test_user_pre_merge_hook_executes() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature worktree with a commit
let feature_wt = repo.add_worktree("feature");
@@ -319,7 +318,6 @@ check = "echo 'USER_PRE_MERGE_RAN' > user_premerge.txt"
fn test_user_pre_merge_hook_failure_blocks_merge() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature worktree with a commit
let feature_wt = repo.add_worktree("feature");
@@ -361,7 +359,6 @@ check = "exit 1"
fn test_user_pre_merge_skipped_with_no_verify() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature worktree with a commit
let feature_wt = repo.add_worktree("feature");
@@ -413,7 +410,6 @@ check = "echo 'USER_PRE_MERGE' > user_premerge_marker.txt"
fn test_user_post_merge_hook_executes() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature worktree with a commit
let feature_wt = repo.add_worktree("feature");
@@ -580,7 +576,6 @@ block = "exit 1"
fn test_user_pre_commit_hook_executes() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature worktree
let feature_wt = repo.add_worktree("feature");
@@ -613,7 +608,6 @@ lint = "echo 'USER_PRE_COMMIT_RAN' > user_precommit.txt"
fn test_user_pre_commit_failure_blocks_commit() {
let mut repo = TestRepo::new();
repo.commit("Initial commit");
- repo.setup_remote("main");
// Create feature worktree
let feature_wt = repo.add_worktree("feature");