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 7 months ago
commit a53ba340c0492719ac4c15bdabadff5f28a4dd24
parent d29ab471d082e39f78a2c3899e412e36bb07779e
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(())
}