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

Function test_target_branch

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

Source from the content-addressed store, hash-verified

715
716 #[test]
717 fn test_target_branch() {
718 let dir = tempfile::tempdir().unwrap();
719 let repo = git2::Repository::init_opts(
720 dir.path(),
721 git2::RepositoryInitOptions::new()
722 .initial_head("main")
723 .mkdir(false),
724 )
725 .unwrap();
726 let sig = git2::Signature::now("Test", "test@example.com").unwrap();
727 let tree_oid = repo.index().unwrap().write_tree().unwrap();
728 let tree = repo.find_tree(tree_oid).unwrap();
729 repo.commit(Some("HEAD"), &sig, &sig, "init", &tree, &[])
730 .unwrap();
731
732 // Default (no override): the checked-out branch.
733 assert_eq!(Push::default().target_branch(&repo, None), "main");
734
735 // A resolved override wins.
736 assert_eq!(Push::default().target_branch(&repo, Some("pr-42")), "pr-42");
737 }
738
739 #[test]
740 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