MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_target_branch

Function test_target_branch

atomic-cli/src/commands/git/push.rs:673–693  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

671
672 #[test]
673 fn test_target_branch() {
674 let dir = tempfile::tempdir().unwrap();
675 let repo = git2::Repository::init_opts(
676 dir.path(),
677 git2::RepositoryInitOptions::new()
678 .initial_head("main")
679 .mkdir(false),
680 )
681 .unwrap();
682 let sig = git2::Signature::now("Test", "test@example.com").unwrap();
683 let tree_oid = repo.index().unwrap().write_tree().unwrap();
684 let tree = repo.find_tree(tree_oid).unwrap();
685 repo.commit(Some("HEAD"), &sig, &sig, "init", &tree, &[])
686 .unwrap();
687
688 // Default (no override): the checked-out branch.
689 assert_eq!(Push::default().target_branch(&repo, None), "main");
690
691 // A resolved override wins.
692 assert_eq!(Push::default().target_branch(&repo, Some("pr-42")), "pr-42");
693 }
694
695 #[test]
696 fn test_resolve_branch_override_explicit_wins() {

Callers

nothing calls this directly

Calls 4

commitMethod · 0.80
unwrapMethod · 0.45
pathMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected