httpd: Don't show unseeded repos
This commit is contained in:
parent
aa9c6542ab
commit
7a5e5ec865
|
|
@ -89,6 +89,7 @@ async fn project_root_handler(
|
||||||
let storage = &ctx.profile.storage;
|
let storage = &ctx.profile.storage;
|
||||||
let db = &ctx.profile.database()?;
|
let db = &ctx.profile.database()?;
|
||||||
let pinned = &ctx.profile.config.web.pinned;
|
let pinned = &ctx.profile.config.web.pinned;
|
||||||
|
let policies = ctx.profile.policies()?;
|
||||||
|
|
||||||
let mut projects = match show {
|
let mut projects = match show {
|
||||||
ProjectQuery::All => storage
|
ProjectQuery::All => storage
|
||||||
|
|
@ -105,14 +106,17 @@ async fn project_root_handler(
|
||||||
|
|
||||||
let infos = projects
|
let infos = projects
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter_map(|id| {
|
.filter_map(|info| {
|
||||||
let Ok(repo) = storage.repository(id.rid) else {
|
if !policies.is_seeding(&info.rid).unwrap_or_default() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let Ok(repo) = storage.repository(info.rid) else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let Ok((_, head)) = repo.head() else {
|
let Ok((_, head)) = repo.head() else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let Ok(payload) = id.doc.project() else {
|
let Ok(payload) = info.doc.project() else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let Ok(issues) = issue::Issues::open(&repo) else {
|
let Ok(issues) = issue::Issues::open(&repo) else {
|
||||||
|
|
@ -127,17 +131,17 @@ async fn project_root_handler(
|
||||||
let Ok(patches) = patches.counts() else {
|
let Ok(patches) = patches.counts() else {
|
||||||
return None;
|
return None;
|
||||||
};
|
};
|
||||||
let delegates = id.doc.delegates;
|
let delegates = info.doc.delegates;
|
||||||
let seeding = db.count(&id.rid).unwrap_or_default();
|
let seeding = db.count(&info.rid).unwrap_or_default();
|
||||||
|
|
||||||
Some(Info {
|
Some(Info {
|
||||||
payload,
|
payload,
|
||||||
delegates,
|
delegates,
|
||||||
head,
|
head,
|
||||||
visibility: id.doc.visibility,
|
visibility: info.doc.visibility,
|
||||||
issues,
|
issues,
|
||||||
patches,
|
patches,
|
||||||
id: id.rid,
|
id: info.rid,
|
||||||
seeding,
|
seeding,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,7 @@ fn seed_with_signer<G: Signer>(dir: &Path, profile: radicle::Profile, signer: &G
|
||||||
profile.policies_mut().unwrap();
|
profile.policies_mut().unwrap();
|
||||||
profile.database_mut().unwrap(); // Create the database.
|
profile.database_mut().unwrap(); // Create the database.
|
||||||
|
|
||||||
|
let mut policies = profile.policies_mut().unwrap();
|
||||||
let workdir = dir.join("hello-world-private");
|
let workdir = dir.join("hello-world-private");
|
||||||
fs::create_dir_all(&workdir).unwrap();
|
fs::create_dir_all(&workdir).unwrap();
|
||||||
|
|
||||||
|
|
@ -125,7 +126,7 @@ fn seed_with_signer<G: Signer>(dir: &Path, profile: radicle::Profile, signer: &G
|
||||||
let visibility = Visibility::Private {
|
let visibility = Visibility::Private {
|
||||||
allow: BTreeSet::default(),
|
allow: BTreeSet::default(),
|
||||||
};
|
};
|
||||||
radicle::rad::init(
|
let (rid, _, _) = radicle::rad::init(
|
||||||
&repo,
|
&repo,
|
||||||
&name,
|
&name,
|
||||||
&description,
|
&description,
|
||||||
|
|
@ -135,6 +136,7 @@ fn seed_with_signer<G: Signer>(dir: &Path, profile: radicle::Profile, signer: &G
|
||||||
&profile.storage,
|
&profile.storage,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
policies.seed(&rid, node::policy::Scope::All).unwrap();
|
||||||
|
|
||||||
let workdir = dir.join("hello-world");
|
let workdir = dir.join("hello-world");
|
||||||
|
|
||||||
|
|
@ -215,7 +217,7 @@ fn seed_with_signer<G: Signer>(dir: &Path, profile: radicle::Profile, signer: &G
|
||||||
let description = "Rad repository for tests".to_string();
|
let description = "Rad repository for tests".to_string();
|
||||||
let branch = RefString::try_from(DEFAULT_BRANCH).unwrap();
|
let branch = RefString::try_from(DEFAULT_BRANCH).unwrap();
|
||||||
let visibility = Visibility::default();
|
let visibility = Visibility::default();
|
||||||
let (id, _, _) = radicle::rad::init(
|
let (rid, _, _) = radicle::rad::init(
|
||||||
&repo,
|
&repo,
|
||||||
&name,
|
&name,
|
||||||
&description,
|
&description,
|
||||||
|
|
@ -225,9 +227,10 @@ fn seed_with_signer<G: Signer>(dir: &Path, profile: radicle::Profile, signer: &G
|
||||||
&profile.storage,
|
&profile.storage,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
policies.seed(&rid, node::policy::Scope::All).unwrap();
|
||||||
|
|
||||||
let storage = &profile.storage;
|
let storage = &profile.storage;
|
||||||
let repo = storage.repository(id).unwrap();
|
let repo = storage.repository(rid).unwrap();
|
||||||
let mut issues = Issues::open(&repo).unwrap();
|
let mut issues = Issues::open(&repo).unwrap();
|
||||||
let issue = issues
|
let issue = issues
|
||||||
.create(
|
.create(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue