ok/jj
1
0
Fork 0
forked from mirrors/jj

git: make fetch() import local tags in addition to remote branches

This commit is contained in:
Yuya Nishihara 2023-09-25 19:31:01 +09:00
parent 88129a3b5c
commit 0ca5cf48db
2 changed files with 16 additions and 4 deletions

View file

@ -914,13 +914,14 @@ pub fn fetch(
tracing::debug!("remote.disconnect");
remote.disconnect()?;
// `import_some_refs` will import the remote-tracking branches into the jj repo
// and update jj's local branches.
// Import the remote-tracking branches into the jj repo and update jj's
// local branches. We also import local tags since remote tags should have
// been merged by Git.
tracing::debug!("import_refs");
import_some_refs(mut_repo, git_repo, git_settings, |ref_name| {
to_remote_branch(ref_name, remote_name)
.map(&branch_name_filter)
.unwrap_or(false)
.unwrap_or_else(|| matches!(ref_name, RefName::Tag(_)))
})?;
Ok(default_branch)
}

View file

@ -1684,6 +1684,10 @@ fn test_fetch_success() {
"refs/heads/main",
&[&initial_git_commit],
);
test_data
.origin_repo
.reference("refs/tags/v1.0", new_git_commit.id(), false, "")
.unwrap();
let mut tx = test_data
.repo
@ -1708,6 +1712,7 @@ fn test_fetch_success() {
*view.git_refs(),
btreemap! {
"refs/remotes/origin/main".to_string() => new_commit_target.clone(),
"refs/tags/v1.0".to_string() => new_commit_target.clone(),
}
);
assert_eq!(
@ -1716,11 +1721,17 @@ fn test_fetch_success() {
"main".to_string() => BranchTarget {
local_target: new_commit_target.clone(),
remote_targets: btreemap! {
"origin".to_string() => new_commit_target,
"origin".to_string() => new_commit_target.clone(),
},
},
}
);
assert_eq!(
*view.tags(),
btreemap! {
"v1.0".to_string() => new_commit_target.clone(),
}
);
}
#[test]