From 91d4ba7158f3d8fc32b2a668cd1153a0d6971087 Mon Sep 17 00:00:00 2001 From: Joseph Frazier <1212jtraceur@gmail.com> Date: Tue, 5 Jan 2016 21:25:04 -0500 Subject: [PATCH] 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. --- Library/Homebrew/cmd/update.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 436175b259..f93224c8d0 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -41,8 +41,9 @@ module Homebrew master_updater.pull! master_updated = master_updater.updated? if master_updated - puts "Updated Homebrew from #{master_updater.initial_revision[0, 8]} " \ - "to #{master_updater.current_revision[0, 8]}." + initial_short = shorten_revision(master_updater.initial_revision) + current_short = shorten_revision(master_updater.current_revision) + puts "Updated Homebrew from #{initial_short} to #{current_short}." end report.update(master_updater.report) @@ -133,6 +134,10 @@ module Homebrew private + def shorten_revision(revision) + `git rev-parse --short #{revision}`.chomp + end + def git_init_if_necessary if Dir[".git/*"].empty? safe_system "git", "init"