forked from mirrors/jj
tests: set git_settings.auto_local_branch where it matters
This commit is contained in:
parent
ac99145a28
commit
6971ec239a
9 changed files with 74 additions and 11 deletions
|
@ -453,6 +453,7 @@ fn test_branch_forget_fetched_branch() {
|
|||
|
||||
// Set up a git repo with a branch and a jj repo that has it as a remote.
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
let git_repo_path = test_env.env_root().join("git-repo");
|
||||
|
@ -568,6 +569,7 @@ fn test_branch_forget_deleted_or_nonexistent_branch() {
|
|||
// ======== Beginning of test setup ========
|
||||
// Set up a git repo with a branch and a jj repo that has it as a remote.
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
let git_repo_path = test_env.env_root().join("git-repo");
|
||||
|
@ -923,6 +925,7 @@ fn test_branch_track_untrack_patterns() {
|
|||
#[test]
|
||||
fn test_branch_list() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
|
||||
// Initialize remote refs
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "remote", "--git"]);
|
||||
|
@ -989,6 +992,7 @@ fn test_branch_list() {
|
|||
#[test]
|
||||
fn test_branch_list_filtered() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "none()""#);
|
||||
|
||||
// Initialize remote refs
|
||||
|
|
|
@ -39,6 +39,7 @@ fn set_up(trunk_name: &str) -> (TestEnvironment, PathBuf) {
|
|||
&[
|
||||
"git",
|
||||
"clone",
|
||||
"--config-toml=git.auto-local-branch=true",
|
||||
origin_git_repo_path.to_str().unwrap(),
|
||||
"local",
|
||||
],
|
||||
|
|
|
@ -365,6 +365,7 @@ fn test_log_obslog_divergence() {
|
|||
#[test]
|
||||
fn test_log_branches() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "none()""#);
|
||||
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "--git", "origin"]);
|
||||
|
|
|
@ -44,6 +44,7 @@ fn set_up_non_empty_git_repo(git_repo: &git2::Repository) {
|
|||
#[test]
|
||||
fn test_git_clone() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let git_repo_path = test_env.env_root().join("source");
|
||||
let git_repo = git2::Repository::init(git_repo_path).unwrap();
|
||||
|
||||
|
@ -140,6 +141,7 @@ fn test_git_clone() {
|
|||
#[test]
|
||||
fn test_git_clone_colocate() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let git_repo_path = test_env.env_root().join("source");
|
||||
let git_repo = git2::Repository::init(git_repo_path).unwrap();
|
||||
|
||||
|
|
|
@ -475,6 +475,7 @@ fn test_git_colocated_checkout_non_empty_working_copy() {
|
|||
#[test]
|
||||
fn test_git_colocated_fetch_deleted_or_moved_branch() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let origin_path = test_env.env_root().join("origin");
|
||||
git2::Repository::init(&origin_path).unwrap();
|
||||
test_env.jj_cmd_ok(&origin_path, &["init", "--git-repo=."]);
|
||||
|
|
|
@ -76,6 +76,7 @@ fn get_log_output(test_env: &TestEnvironment, workspace_root: &Path) -> String {
|
|||
#[test]
|
||||
fn test_git_fetch_default_remote() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "origin");
|
||||
|
@ -90,6 +91,7 @@ fn test_git_fetch_default_remote() {
|
|||
#[test]
|
||||
fn test_git_fetch_single_remote() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "rem1");
|
||||
|
@ -108,6 +110,7 @@ fn test_git_fetch_single_remote() {
|
|||
#[test]
|
||||
fn test_git_fetch_single_remote_all_remotes_flag() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "rem1");
|
||||
|
@ -125,6 +128,7 @@ fn test_git_fetch_single_remote_all_remotes_flag() {
|
|||
#[test]
|
||||
fn test_git_fetch_single_remote_from_arg() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "rem1");
|
||||
|
@ -139,6 +143,7 @@ fn test_git_fetch_single_remote_from_arg() {
|
|||
#[test]
|
||||
fn test_git_fetch_single_remote_from_config() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "rem1");
|
||||
|
@ -154,6 +159,7 @@ fn test_git_fetch_single_remote_from_config() {
|
|||
#[test]
|
||||
fn test_git_fetch_multiple_remotes() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "rem1");
|
||||
|
@ -174,6 +180,7 @@ fn test_git_fetch_multiple_remotes() {
|
|||
#[test]
|
||||
fn test_git_fetch_all_remotes() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "rem1");
|
||||
|
@ -191,6 +198,7 @@ fn test_git_fetch_all_remotes() {
|
|||
#[test]
|
||||
fn test_git_fetch_multiple_remotes_from_config() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "rem1");
|
||||
|
@ -243,6 +251,7 @@ fn test_git_fetch_nonexistent_remote_from_config() {
|
|||
#[test]
|
||||
fn test_git_fetch_from_remote_named_git() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
init_git_remote(&test_env, "git");
|
||||
let git_repo = git2::Repository::init(&repo_path).unwrap();
|
||||
|
@ -286,6 +295,7 @@ fn test_git_fetch_from_remote_named_git() {
|
|||
#[test]
|
||||
fn test_git_fetch_prune_before_updating_tips() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "origin");
|
||||
|
@ -313,6 +323,7 @@ fn test_git_fetch_prune_before_updating_tips() {
|
|||
#[test]
|
||||
fn test_git_fetch_conflicting_branches() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "rem1");
|
||||
|
@ -340,6 +351,7 @@ fn test_git_fetch_conflicting_branches() {
|
|||
#[test]
|
||||
fn test_git_fetch_conflicting_branches_colocated() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
let _git_repo = git2::Repository::init(&repo_path).unwrap();
|
||||
// create_colocated_repo_and_branches_from_trunk1(&test_env, &repo_path);
|
||||
|
@ -402,6 +414,7 @@ fn create_trunk2_and_rebase_branches(test_env: &TestEnvironment, repo_path: &Pat
|
|||
#[test]
|
||||
fn test_git_fetch_all() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "none()""#);
|
||||
let source_git_repo_path = test_env.env_root().join("source");
|
||||
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
|
||||
|
@ -541,6 +554,7 @@ fn test_git_fetch_all() {
|
|||
#[test]
|
||||
fn test_git_fetch_some_of_many_branches() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.add_config(r#"revset-aliases."immutable_heads()" = "none()""#);
|
||||
let source_git_repo_path = test_env.env_root().join("source");
|
||||
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
|
||||
|
@ -750,6 +764,7 @@ fn test_git_fetch_some_of_many_branches() {
|
|||
#[test]
|
||||
fn test_git_fetch_undo() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let source_git_repo_path = test_env.env_root().join("source");
|
||||
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
|
||||
|
||||
|
@ -819,6 +834,7 @@ fn test_git_fetch_undo() {
|
|||
#[test]
|
||||
fn test_fetch_undo_what() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let source_git_repo_path = test_env.env_root().join("source");
|
||||
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
|
||||
|
||||
|
@ -910,6 +926,7 @@ fn test_fetch_undo_what() {
|
|||
#[test]
|
||||
fn test_git_fetch_remove_fetch() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "origin");
|
||||
|
@ -951,6 +968,7 @@ fn test_git_fetch_remove_fetch() {
|
|||
#[test]
|
||||
fn test_git_fetch_rename_fetch() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
|
||||
let repo_path = test_env.env_root().join("repo");
|
||||
add_git_remote(&test_env, &repo_path, "origin");
|
||||
|
@ -991,6 +1009,7 @@ fn test_git_fetch_rename_fetch() {
|
|||
#[test]
|
||||
fn test_git_fetch_removed_branch() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let source_git_repo_path = test_env.env_root().join("source");
|
||||
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
|
||||
|
||||
|
@ -1076,6 +1095,7 @@ fn test_git_fetch_removed_branch() {
|
|||
#[test]
|
||||
fn test_git_fetch_removed_parent_branch() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let source_git_repo_path = test_env.env_root().join("source");
|
||||
let _git_repo = git2::Repository::init(source_git_repo_path.clone()).unwrap();
|
||||
|
||||
|
@ -1179,7 +1199,8 @@ fn test_git_fetch_remote_only_branch() {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
// Fetch normally
|
||||
// Fetch using git.auto_local_branch = true
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
test_env.jj_cmd_ok(&repo_path, &["git", "fetch", "--remote=origin"]);
|
||||
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
|
||||
feature1: mzyxwzks 9f01a0e0 message
|
||||
|
|
|
@ -39,6 +39,7 @@ fn set_up() -> (TestEnvironment, PathBuf) {
|
|||
&[
|
||||
"git",
|
||||
"clone",
|
||||
"--config-toml=git.auto-local-branch=true",
|
||||
origin_git_repo_path.to_str().unwrap(),
|
||||
"local",
|
||||
],
|
||||
|
@ -681,6 +682,7 @@ fn test_git_push_deleted() {
|
|||
#[test]
|
||||
fn test_git_push_conflicting_branches() {
|
||||
let (test_env, workspace_root) = set_up();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
let git_repo = {
|
||||
let mut git_repo_path = workspace_root.clone();
|
||||
git_repo_path.extend([".jj", "repo", "store", "git"]);
|
||||
|
|
|
@ -369,6 +369,7 @@ fn test_init_git_colocated_symlink_gitlink() {
|
|||
#[test]
|
||||
fn test_init_git_colocated_imported_refs() {
|
||||
let test_env = TestEnvironment::default();
|
||||
test_env.add_config("git.auto-local-branch = true");
|
||||
|
||||
// Set up remote refs
|
||||
test_env.jj_cmd_ok(test_env.env_root(), &["init", "remote", "--git"]);
|
||||
|
|
|
@ -88,7 +88,10 @@ fn get_git_repo(repo: &Arc<ReadonlyRepo>) -> git2::Repository {
|
|||
#[test]
|
||||
fn test_import_refs() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
let git_repo = get_git_repo(repo);
|
||||
|
@ -210,7 +213,10 @@ fn test_import_refs() {
|
|||
#[test]
|
||||
fn test_import_refs_reimport() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_workspace.repo;
|
||||
let git_repo = get_git_repo(repo);
|
||||
|
@ -446,7 +452,10 @@ fn test_import_refs_reimport_git_head_with_moved_ref() {
|
|||
#[test]
|
||||
fn test_import_refs_reimport_with_deleted_remote_ref() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_workspace.repo;
|
||||
let git_repo = get_git_repo(repo);
|
||||
|
@ -562,7 +571,10 @@ fn test_import_refs_reimport_with_deleted_remote_ref() {
|
|||
#[test]
|
||||
fn test_import_refs_reimport_with_moved_remote_ref() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_workspace.repo;
|
||||
let git_repo = get_git_repo(repo);
|
||||
|
@ -854,7 +866,10 @@ fn test_import_refs_reimport_abandoning_disabled() {
|
|||
#[test]
|
||||
fn test_import_refs_reimport_conflicted_remote_branch() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let test_repo = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_repo.repo;
|
||||
let git_repo = get_git_repo(repo);
|
||||
|
@ -918,7 +933,10 @@ fn test_import_refs_reserved_remote_name() {
|
|||
#[test]
|
||||
fn test_import_some_refs() {
|
||||
let settings = testutils::user_settings();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let test_workspace = TestRepo::init_with_backend(TestRepoBackend::Git);
|
||||
let repo = &test_workspace.repo;
|
||||
let git_repo = get_git_repo(repo);
|
||||
|
@ -1999,7 +2017,10 @@ fn test_fetch_empty_repo() {
|
|||
#[test]
|
||||
fn test_fetch_initial_commit() {
|
||||
let test_data = GitRepoData::create();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let initial_git_commit = empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]);
|
||||
|
||||
let mut tx = test_data.repo.start_transaction(&test_data.settings);
|
||||
|
@ -2046,7 +2067,10 @@ fn test_fetch_initial_commit() {
|
|||
#[test]
|
||||
fn test_fetch_success() {
|
||||
let mut test_data = GitRepoData::create();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let initial_git_commit = empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]);
|
||||
|
||||
let mut tx = test_data.repo.start_transaction(&test_data.settings);
|
||||
|
@ -2123,7 +2147,10 @@ fn test_fetch_success() {
|
|||
#[test]
|
||||
fn test_fetch_prune_deleted_ref() {
|
||||
let test_data = GitRepoData::create();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let commit = empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]);
|
||||
|
||||
let mut tx = test_data.repo.start_transaction(&test_data.settings);
|
||||
|
@ -2162,7 +2189,10 @@ fn test_fetch_prune_deleted_ref() {
|
|||
#[test]
|
||||
fn test_fetch_no_default_branch() {
|
||||
let test_data = GitRepoData::create();
|
||||
let git_settings = GitSettings::default();
|
||||
let git_settings = GitSettings {
|
||||
auto_local_branch: true,
|
||||
..Default::default()
|
||||
};
|
||||
let initial_git_commit = empty_git_commit(&test_data.origin_repo, "refs/heads/main", &[]);
|
||||
|
||||
let mut tx = test_data.repo.start_transaction(&test_data.settings);
|
||||
|
|
Loading…
Reference in a new issue