cli/patch: Replace manual building table from iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
41a742ed9b
commit
fb458537b4
|
|
@ -306,18 +306,20 @@ pub fn get_update_message(
|
||||||
|
|
||||||
/// List the given commits in a table.
|
/// List the given commits in a table.
|
||||||
pub fn list_commits(commits: &[git::raw::Commit]) -> anyhow::Result<()> {
|
pub fn list_commits(commits: &[git::raw::Commit]) -> anyhow::Result<()> {
|
||||||
let mut table = term::Table::default();
|
commits
|
||||||
|
.iter()
|
||||||
|
.map(|commit| {
|
||||||
|
let message = commit
|
||||||
|
.summary_bytes()
|
||||||
|
.unwrap_or_else(|| commit.message_bytes());
|
||||||
|
|
||||||
for commit in commits {
|
[
|
||||||
let message = commit
|
term::format::secondary(term::format::oid(commit.id()).into()),
|
||||||
.summary_bytes()
|
term::format::italic(String::from_utf8_lossy(message).to_string()),
|
||||||
.unwrap_or_else(|| commit.message_bytes());
|
]
|
||||||
table.push([
|
})
|
||||||
term::format::secondary(term::format::oid(commit.id()).into()),
|
.collect::<term::Table<2, _>>()
|
||||||
term::format::italic(String::from_utf8_lossy(message).to_string()),
|
.print();
|
||||||
]);
|
|
||||||
}
|
|
||||||
table.print();
|
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue