aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/update.rb
diff options
context:
space:
mode:
authorJack Nagel2012-03-22 18:22:39 -0500
committerJack Nagel2012-03-22 22:15:57 -0500
commit9076037a0df37f79d0556bac683cc3b1c9742fe6 (patch)
tree892e00424ffba29b217416e4c8d7cd307e3dc383 /Library/Homebrew/cmd/update.rb
parent10f8443f8ae9f008c2bc45b0e80bcbb2f6419806 (diff)
downloadbrew-9076037a0df37f79d0556bac683cc3b1c9742fe6.tar.bz2
Detect and display renames in `brew update`
Renamed formulae will cease to display as an add/delete pair and instead end up the in the "Renamed" section. In the future we should be able to take this information and use it to rename existing kegs during updates, allowing us to rename formulae without breaking upgrades. Renaming a formula requires renaming the class, so there will be at least one add/delete pair in the file. Thus, the similarity threshold for detecting renames is set at 85% to allow a little bit of content turnover without losing track of the rename. Closes Homebrew/homebrew#11158. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/cmd/update.rb')
-rw-r--r--Library/Homebrew/cmd/update.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb
index e3e25c01e..594d2da95 100644
--- a/Library/Homebrew/cmd/update.rb
+++ b/Library/Homebrew/cmd/update.rb
@@ -84,10 +84,15 @@ class Updater
map = Hash.new{ |h,k| h[k] = [] }
if initial_revision && initial_revision != current_revision
- changes = `git diff-tree -r --name-status -z #{initial_revision} #{current_revision}`.split("\0")
- changes.each_slice(2) do |status, file|
- file = Pathname.pwd.join(file).relative_path_from(HOMEBREW_REPOSITORY)
- map[status.to_sym] << file.to_s
+ changes = `git diff-tree -r --name-status -M85% -z #{initial_revision} #{current_revision}`.split("\0")
+ changes.each_cons(3) do |status, src, dst|
+ next unless status =~ /^[AMDR](\d{3})?$/
+ path = case status = status[0,1]
+ when 'R' then dst
+ else src
+ end
+ path = Pathname.pwd.join(path).relative_path_from(HOMEBREW_REPOSITORY)
+ map[status.to_sym] << path.to_s
end
end