mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-18 19:10:45 +08:00
Fix contributor filter in list_repos & repo_count
- the previous list_repos / repo_count predicates only matched SignedRefsInfo::Some, so a forked repo whose sigrefs predate the current FeatureLevel (NeedsMigration) was hidden from the contributor view and undercounted - add is_contributor helper so the two call sites can't drift again (they already had — list_repos was inverted from repo_count after the 0.22 sigrefs refactor) See discussion for more info https://radicle.zulipchat.com/#narrow/channel/369277-heartwood/topic/.60SignedRefsInfo.3A.3ANeedsMigration.60.20and.20local.20signed.20refs/with/594265582
This commit is contained in:
@@ -32,6 +32,16 @@ pub enum Show {
|
||||
Private,
|
||||
}
|
||||
|
||||
/// A repo counts as one the local node contributes to whenever it has
|
||||
/// local signed refs, even if those refs are at an outdated feature
|
||||
/// level pending node-side migration.
|
||||
fn is_contributor(refs: &storage::SignedRefsInfo) -> bool {
|
||||
matches!(
|
||||
refs,
|
||||
storage::SignedRefsInfo::Some(_) | storage::SignedRefsInfo::NeedsMigration,
|
||||
)
|
||||
}
|
||||
|
||||
pub trait Repo: Profile {
|
||||
fn list_repos(&self, show: Show) -> Result<Vec<repo::RepoInfo>, Error> {
|
||||
let profile = self.profile();
|
||||
@@ -41,9 +51,7 @@ pub trait Repo: Profile {
|
||||
let mut entries = Vec::new();
|
||||
|
||||
for RepositoryInfo { rid, doc, refs, .. } in repos {
|
||||
if matches!(refs, radicle::storage::SignedRefsInfo::Some(_))
|
||||
&& show == Show::Contributor
|
||||
{
|
||||
if !is_contributor(&refs) && show == Show::Contributor {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -126,7 +134,7 @@ pub trait Repo: Profile {
|
||||
delegate += 1;
|
||||
}
|
||||
|
||||
if matches!(refs, radicle::storage::SignedRefsInfo::Some(_)) {
|
||||
if is_contributor(&refs) {
|
||||
contributor += 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user