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

Function test_target_branch

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

Source from the content-addressed store, hash-verified

596
597 #[test]
598 fn test_target_branch() {
599 let dir = tempfile::tempdir().unwrap();
600 let repo = git2::Repository::init_opts(
601 dir.path(),
602 git2::RepositoryInitOptions::new()
603 .initial_head("main")
604 .mkdir(false),
605 )
606 .unwrap();
607 let sig = git2::Signature::now("Test", "test@example.com").unwrap();
608 let tree_oid = repo.index().unwrap().write_tree().unwrap();
609 let tree = repo.find_tree(tree_oid).unwrap();
610 repo.commit(Some("HEAD"), &sig, &sig, "init", &tree, &[])
611 .unwrap();
612
613 // Default: the checked-out branch.
614 assert_eq!(Push::default().target_branch(&repo), "main");
615
616 // --branch wins.
617 let push = Push {
618 branch: Some("pr-42".to_string()),
619 ..Push::default()
620 };
621 assert_eq!(push.target_branch(&repo), "pr-42");
622 }
623}

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