Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: reduce `rad ls` dependency
Slack Coder committed 3 years ago
commit 3e87e5f9eb08f79e6797f7f541bdf47ada3a0979
parent 2598886018db208ddc04a68a3e160daa93ddd7f0
2 files changed +11 -8
modified 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(())
modified radicle/src/storage/git.rs
@@ -298,9 +298,11 @@ impl Repository {
        Identity::load_at(head, self)
    }

-
    pub fn project_of(&self, remote: &RemoteId) -> Result<Project, IdentityError> {
-
        let doc = self.identity_doc_of(remote)?;
-
        let proj = doc.project()?;
+
    /// Get the canonical project information.
+
    pub fn project(&self) -> Result<Project, IdentityError> {
+
        let head = self.identity_head()?;
+
        let doc = self.identity_doc_at(head)?;
+
        let proj = doc.verified()?.project()?;

        Ok(proj)
    }