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

Function test_target_branch

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

Source from the content-addressed store, hash-verified

1147
1148 #[test]
1149 fn test_target_branch() {
1150 let dir = tempfile::tempdir().unwrap();
1151 let repo = git2::Repository::init_opts(
1152 dir.path(),
1153 git2::RepositoryInitOptions::new()
1154 .initial_head("main")
1155 .mkdir(false),
1156 )
1157 .unwrap();
1158 let sig = git2::Signature::now("Test", "test@example.com").unwrap();
1159 let tree_oid = repo.index().unwrap().write_tree().unwrap();
1160 let tree = repo.find_tree(tree_oid).unwrap();
1161 repo.commit(Some("HEAD"), &sig, &sig, "init", &tree, &[])
1162 .unwrap();
1163
1164 // Default (no override): the checked-out branch.
1165 assert_eq!(Push::default().target_branch(&repo, None), "main");
1166
1167 // A resolved override wins.
1168 assert_eq!(Push::default().target_branch(&repo, Some("pr-42")), "pr-42");
1169 }
1170
1171 #[test]
1172 fn test_resolve_branch_override_explicit_wins() {

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected