update: abbreviate hashes to at least 7 characters

Abbreviations will be longer if needed to preserve uniqueness.

This makes it more consistent with `git rev-parse --short`,
https://github.com/Homebrew/homebrew/commits, etc.

For example, instead of:

    Updated Homebrew from 40d1e9c2 to 90b9bdf4.

We see:

    Updated Homebrew from 40d1e9c to 90b9bdf.

See 0c48248b6555353c8d60b61973639c8423ce586c for the original
introduction of eight-character abbreviations.
This commit is contained in:
Joseph Frazier 2016-01-05 21:25:04 -05:00 committed by Martin Afanasjew
parent 5162df8f65
commit 91d4ba7158

View File

@ -41,8 +41,9 @@ module Homebrew
master_updater.pull! master_updater.pull!
master_updated = master_updater.updated? master_updated = master_updater.updated?
if master_updated if master_updated
puts "Updated Homebrew from #{master_updater.initial_revision[0, 8]} " \ initial_short = shorten_revision(master_updater.initial_revision)
"to #{master_updater.current_revision[0, 8]}." current_short = shorten_revision(master_updater.current_revision)
puts "Updated Homebrew from #{initial_short} to #{current_short}."
end end
report.update(master_updater.report) report.update(master_updater.report)
@ -133,6 +134,10 @@ module Homebrew
private private
def shorten_revision(revision)
`git rev-parse --short #{revision}`.chomp
end
def git_init_if_necessary def git_init_if_necessary
if Dir[".git/*"].empty? if Dir[".git/*"].empty?
safe_system "git", "init" safe_system "git", "init"