Skip to content

Commit 71f245a

Browse files
authored
Merge pull request #53 from arvidboivie/feature/short-commit-hash
Shorten commit hash to 7 characters
2 parents 6474be0 + c51b68d commit 71f245a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/main.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,14 @@ impl CommitInfo {
248248

249249
impl fmt::Display for CommitInfo {
250250
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
251+
let short_commit = self.commit.to_string().chars().take(7).collect::<String>();
251252
if self.refs.len() > 0 {
252253
let refs_str = self.refs.iter().map(|ref_name| {
253254
ref_name.as_str()
254255
}).collect::<Vec<&str>>().join(", ");
255-
write!(f, "{} ({})", self.commit, refs_str)
256+
write!(f, "{} ({})", short_commit, refs_str)
256257
} else {
257-
write!(f, "{}", self.commit)
258+
write!(f, "{}", short_commit)
258259
}
259260
}
260261
}

0 commit comments

Comments
 (0)