MCPcopy Create free account
hub / github.com/dashed/git-chain / merge_subcommand_deep_chain

Function merge_subcommand_deep_chain

tests/merge.rs:5441–5685  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5439/// Test deep chains (3+ levels) with merge feature
5440#[test]
5441fn merge_subcommand_deep_chain() {
5442 println!("=== TEST SETUP: MERGE SUBCOMMAND DEEP CHAIN ===");
5443 let repo_name = "merge_deep_chain";
5444 let repo = setup_git_repo(repo_name);
5445 let path_to_repo = generate_path_to_repo(repo_name);
5446
5447 // Helper function to get git log
5448 let get_git_log = |branch_name: &str, num_entries: &str| -> String {
5449 let output = run_git_command(
5450 &path_to_repo,
5451 vec!["log", "--oneline", "-n", num_entries, branch_name],
5452 );
5453 String::from_utf8_lossy(&output.stdout).to_string()
5454 };
5455
5456 // Helper function to check if file exists
5457 let file_exists = |filename: &str| -> bool {
5458 std::path::Path::new(&format!("{}/{}", path_to_repo.to_string_lossy(), filename)).exists()
5459 };
5460
5461 println!("=== REPOSITORY AND DEEP CHAIN INITIALIZATION ===");
5462 // Create initial repository with a deep chain (5 levels)
5463 {
5464 create_new_file(&path_to_repo, "hello_world.txt", "Hello, world!");
5465 first_commit_all(&repo, "first commit");
5466
5467 // Create branches for deep chain
5468 let branch_names = [
5469 "feature_1",
5470 "feature_2",
5471 "feature_3",
5472 "feature_4",
5473 "feature_5",
5474 ];
5475
5476 println!(
5477 "Creating deep chain with {} branches: {}",
5478 branch_names.len(),
5479 branch_names.join(" -> ")
5480 );
5481
5482 for (i, branch_name) in branch_names.iter().enumerate() {
5483 if i == 0 {
5484 // First branch based on master
5485 println!("Creating first branch {} from master", branch_name);
5486 create_branch(&repo, branch_name);
5487 checkout_branch(&repo, branch_name);
5488 } else {
5489 // Subsequent branches based on previous branch
5490 println!(
5491 "Creating branch {} from {}",
5492 branch_name,
5493 branch_names[i - 1]
5494 );
5495 create_branch(&repo, branch_name);
5496 checkout_branch(&repo, branch_name);
5497 }
5498

Callers

nothing calls this directly

Calls 12

setup_git_repoFunction · 0.85
generate_path_to_repoFunction · 0.85
run_git_commandFunction · 0.85
create_new_fileFunction · 0.85
first_commit_allFunction · 0.85
create_branchFunction · 0.85
checkout_branchFunction · 0.85
commit_allFunction · 0.85
run_test_bin_expect_okFunction · 0.85
get_current_branch_nameFunction · 0.85
get_git_logFunction · 0.85
teardown_git_repoFunction · 0.85

Tested by

no test coverage detected