Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/patch: Replace manual building table from iterator
Matthias Beyer committed 8 months ago
commit fb458537b458664dc8b43ea9de823fda66d663e6
parent 41a742ed9be97ca9d4279b4e34d8006f5675d34e
1 file changed +14 -12
modified crates/radicle-cli/src/terminal/patch.rs
@@ -306,18 +306,20 @@ pub fn get_update_message(

/// List the given commits in a table.
pub fn list_commits(commits: &[git::raw::Commit]) -> anyhow::Result<()> {
-
    let mut table = term::Table::default();
-

-
    for commit in commits {
-
        let message = commit
-
            .summary_bytes()
-
            .unwrap_or_else(|| commit.message_bytes());
-
        table.push([
-
            term::format::secondary(term::format::oid(commit.id()).into()),
-
            term::format::italic(String::from_utf8_lossy(message).to_string()),
-
        ]);
-
    }
-
    table.print();
+
    commits
+
        .iter()
+
        .map(|commit| {
+
            let message = commit
+
                .summary_bytes()
+
                .unwrap_or_else(|| commit.message_bytes());
+

+
            [
+
                term::format::secondary(term::format::oid(commit.id()).into()),
+
                term::format::italic(String::from_utf8_lossy(message).to_string()),
+
            ]
+
        })
+
        .collect::<term::Table<2, _>>()
+
        .print();

    Ok(())
}