git: mark imported remote-tracking branches as public

This commit is contained in:
Martin von Zweigbergk 2021-01-16 11:48:35 -08:00
parent 4db3d8d3a6
commit 79eecb6119
2 changed files with 7 additions and 0 deletions

View File

@ -55,6 +55,11 @@ pub fn import_refs(
let commit = store.get_commit(&id).unwrap();
tx.add_head(&commit);
tx.insert_git_ref(git_ref.name().unwrap().to_string(), id);
// For now, we consider all remotes "publishing".
// TODO: Make it configurable which remotes are publishing.
if git_ref.is_remote() {
tx.add_public_head(&commit);
}
}
Ok(())
}

View File

@ -80,6 +80,8 @@ fn test_import_refs() {
.cloned()
.collect();
assert_eq!(heads_after, expected_heads);
let public_heads_after: HashSet<_> = view.public_heads().cloned().collect();
assert_eq!(public_heads_after, hashset!(commit_id(&commit5)));
assert_eq!(view.git_refs().len(), 4);
assert_eq!(
view.git_refs().get("refs/heads/main"),