diff --git a/radicle-cli/src/commands/ls.rs b/radicle-cli/src/commands/ls.rs index ea310e71..c34994c3 100644 --- a/radicle-cli/src/commands/ls.rs +++ b/radicle-cli/src/commands/ls.rs @@ -48,10 +48,11 @@ pub fn run(_options: Options, ctx: impl term::Context) -> anyhow::Result<()> { let storage = &profile.storage; let mut table = term::Table::default(); - storage.repositories()?.into_iter().for_each(|id| { - let Ok(repo) = storage.repository(id) else { return }; - let Ok((_, head)) = repo.head() else { return }; - let Ok(proj) = repo.project_of(profile.id()) else { return }; + for id in storage.repositories()? { + let Ok(repo) = storage.repository(id) else { continue }; + let Ok((_, head)) = repo.head() else { continue }; + let Ok(proj) = repo.project() else { continue }; + let head = term::format::oid(head); table.push([ term::format::bold(proj.name().to_owned()), @@ -59,7 +60,7 @@ pub fn run(_options: Options, ctx: impl term::Context) -> anyhow::Result<()> { term::format::secondary(head), term::format::italic(proj.description().to_owned()), ]); - }); + } table.print(); Ok(()) diff --git a/radicle/src/storage/git.rs b/radicle/src/storage/git.rs index 8a6909f3..95d1ca19 100644 --- a/radicle/src/storage/git.rs +++ b/radicle/src/storage/git.rs @@ -298,9 +298,11 @@ impl Repository { Identity::load_at(head, self) } - pub fn project_of(&self, remote: &RemoteId) -> Result { - let doc = self.identity_doc_of(remote)?; - let proj = doc.project()?; + /// Get the canonical project information. + pub fn project(&self) -> Result { + let head = self.identity_head()?; + let doc = self.identity_doc_at(head)?; + let proj = doc.verified()?.project()?; Ok(proj) }