From 79eecb61196c48073b5e8ee7f6cd7608a606f7e5 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 16 Jan 2021 11:48:35 -0800 Subject: [PATCH] git: mark imported remote-tracking branches as public --- lib/src/git.rs | 5 +++++ lib/tests/test_git.rs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/src/git.rs b/lib/src/git.rs index 6f5ede03b..da72d01f5 100644 --- a/lib/src/git.rs +++ b/lib/src/git.rs @@ -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(()) } diff --git a/lib/tests/test_git.rs b/lib/tests/test_git.rs index 7581e3033..4a8cc751d 100644 --- a/lib/tests/test_git.rs +++ b/lib/tests/test_git.rs @@ -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"),