Skip to content

Commit 1cc6809

Browse files
committed
fix branch tests
As prev. behavior was pushing without `brach.*.merge` check, situation like `r1branch.merge = refs/heads/master` would end up pushing to remote r1branch. Which is changed in prev. commits. New behavior would push to remote master To comply with tests, this commit enchance `clone_branch_commit_push` by _explicitly_ resetting branch upstream. So on push it will create new remote ref, as nothing was configured. This behavior is expected to happen in `test_remotes_of_branches` test
1 parent eb5b78a commit 1cc6809

File tree

1 file changed

+10
-0
lines changed
  • asyncgit/src/sync/branch

1 file changed

+10
-0
lines changed

asyncgit/src/sync/branch/mod.rs

+10
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,21 @@ mod tests_branches {
568568
);
569569
}
570570

571+
fn branch_set_upstream(repo_path: &RepoPath, branch_ref: &str, upstream: Option<&str>) -> Result<()> {
572+
let repo = repo(repo_path)?;
573+
let branch_as_ref = repo.find_reference(branch_ref)?;
574+
let mut branch = git2::Branch::wrap(branch_as_ref);
575+
branch.set_upstream(upstream)?;
576+
577+
Ok(())
578+
}
579+
571580
fn clone_branch_commit_push(target: &str, branch_name: &str) {
572581
let (dir, repo) = repo_clone(target).unwrap();
573582
let dir = dir.path().to_str().unwrap();
574583

575584
write_commit_file(&repo, "f1.txt", "foo", "c1");
585+
branch_set_upstream(&dir.into(), "refs/heads/master", None).unwrap();
576586
rename_branch(&dir.into(), "refs/heads/master", branch_name)
577587
.unwrap();
578588
push_branch(

0 commit comments

Comments
 (0)