diff options
| author | Jack Nagel | 2012-03-23 20:39:24 -0500 |
|---|---|---|
| committer | Jack Nagel | 2012-03-23 20:39:24 -0500 |
| commit | 8c4e7ca5b57a60e1ba002a0e949b920a6583c9aa (patch) | |
| tree | 858c988754025c25583f7d2a0f81bb7a50d9162e /Library/Homebrew | |
| parent | 1bc631369494433714c5174dcd51511078377980 (diff) | |
| download | brew-8c4e7ca5b57a60e1ba002a0e949b920a6583c9aa.tar.bz2 | |
Parse raw diff output in `brew update`
Using each_cons() "works", but to report all changes correctly we need
to look at the last elements even after we've looked at the last 3
consecutive elements.
Instead, let's parse each line of the raw diff output using a regexp.
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew')
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 594d2da95..26edaf204 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -80,19 +80,21 @@ class Updater @current_revision = read_current_revision end + # Matches raw git diff format (see `man git-diff-tree`) + DIFFTREE_RX = /^:[0-7]{6} [0-7]{6} [0-9a-fA-F]{40} [0-9a-fA-F]{40} ([ACDMR])\d{0,3}\t(.+?)(?:\t(.+))?$/ + def report map = Hash.new{ |h,k| h[k] = [] } if initial_revision && initial_revision != current_revision - 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 + `git diff-tree -r --raw -M85% #{initial_revision} #{current_revision}`.each_line do |line| + DIFFTREE_RX.match line + path = case status = $1.to_sym + when :R then $3 + else $2 end path = Pathname.pwd.join(path).relative_path_from(HOMEBREW_REPOSITORY) - map[status.to_sym] << path.to_s + map[status] << path.to_s end end |
