Skip to content

Commit

Permalink
Merge pull request #53 from arvidboivie/feature/short-commit-hash
Browse files Browse the repository at this point in the history
Shorten commit hash to 7 characters
  • Loading branch information
o2sh authored Oct 4, 2019
2 parents 6474be0 + c51b68d commit 71f245a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +248,14 @@ impl CommitInfo {

impl fmt::Display for CommitInfo {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let short_commit = self.commit.to_string().chars().take(7).collect::<String>();
if self.refs.len() > 0 {
let refs_str = self.refs.iter().map(|ref_name| {
ref_name.as_str()
}).collect::<Vec<&str>>().join(", ");
write!(f, "{} ({})", self.commit, refs_str)
write!(f, "{} ({})", short_commit, refs_str)
} else {
write!(f, "{}", self.commit)
write!(f, "{}", short_commit)
}
}
}
Expand Down

0 comments on commit 71f245a

Please sign in to comment.