Increase short SHA length to 7 characters (#11492)

This PR increases the length of a shortened Git SHA from 6 to 7
characters.

This matches what GitHub uses.

I also took the opportunity to factor out a common method for computing
a short SHA so that we have a single source of truth for the length that
we're using.

Release Notes:

- Increased the short commit SHA length used by git blame from 6 to 7
characters.
This commit is contained in:
Marshall Bowers 2024-05-07 11:10:44 -04:00 committed by GitHub
parent fc4ea55d3c
commit c77d2eb73f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 4 deletions

View file

@ -37,6 +37,11 @@ impl Oid {
pub(crate) fn is_zero(&self) -> bool {
self.0.is_zero()
}
/// Returns this [`Oid`] as a short SHA.
pub fn display_short(&self) -> String {
self.to_string().chars().take(7).collect()
}
}
impl FromStr for Oid {