Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push with refspec #2542

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tests: cover get_branch_upstream_merge
vlad-anger committed Mar 17, 2025

Verified

This commit was signed with the committer’s verified signature.
commit b004fd52139f9aef1c1d2b67592da4b15294986b
43 changes: 43 additions & 0 deletions asyncgit/src/sync/branch/mod.rs
Original file line number Diff line number Diff line change
@@ -692,6 +692,49 @@ mod tests_branches {

assert!(get_branch_remote(repo_path, "foo").is_err());
}

#[test]
fn test_branch_no_upstream_merge_config() {
let (_r, repo) = repo_init().unwrap();
let root = repo.path().parent().unwrap();
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

let upstream_merge_res =
get_branch_upstream_merge(&repo_path, "master");
assert!(
upstream_merge_res.is_ok_and(|v| v.as_ref().is_none())
);
}

#[test]
fn test_branch_with_upstream_merge_config() {
let (_r, repo) = repo_init().unwrap();
let root = repo.path().parent().unwrap();
let repo_path: &RepoPath =
&root.as_os_str().to_str().unwrap().into();

let branch_name = "master";
let upstrem_merge = "refs/heads/master";

let mut config = repo.config().unwrap();
config
.set_str(
&format!("branch.{branch_name}.merge"),
&upstrem_merge,
)
.expect("fail set branch merge config");

let upstream_merge_res =
get_branch_upstream_merge(&repo_path, &branch_name);
assert!(upstream_merge_res
.as_ref()
.is_ok_and(|v| v.as_ref().is_some()));
assert_eq!(
&upstream_merge_res.unwrap().unwrap(),
upstrem_merge
);
}
}

#[cfg(test)]