Separate reading and parsing the diff
This commit is contained in:
parent
6baf357f8c
commit
802775078c
@ -172,7 +172,7 @@ class Updater
|
|||||||
map = Hash.new{ |h,k| h[k] = [] }
|
map = Hash.new{ |h,k| h[k] = [] }
|
||||||
|
|
||||||
if initial_revision && initial_revision != current_revision
|
if initial_revision && initial_revision != current_revision
|
||||||
`git diff-tree -r --name-status --diff-filter=AMD #{initial_revision} #{current_revision}`.each_line do |line|
|
diff.each_line do |line|
|
||||||
status, path = line.split
|
status, path = line.split
|
||||||
map[status.to_sym] << repository.join(path)
|
map[status.to_sym] << repository.join(path)
|
||||||
end
|
end
|
||||||
@ -187,6 +187,10 @@ class Updater
|
|||||||
`git rev-parse -q --verify HEAD`.chomp
|
`git rev-parse -q --verify HEAD`.chomp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def diff
|
||||||
|
`git diff-tree -r --name-status --diff-filter=AMD #{initial_revision} #{current_revision}`
|
||||||
|
end
|
||||||
|
|
||||||
def `(cmd)
|
def `(cmd)
|
||||||
out = super
|
out = super
|
||||||
if $? && !$?.success?
|
if $? && !$?.success?
|
||||||
|
|||||||
@ -4,6 +4,8 @@ require 'yaml'
|
|||||||
|
|
||||||
class UpdaterTests < Homebrew::TestCase
|
class UpdaterTests < Homebrew::TestCase
|
||||||
class UpdaterMock < ::Updater
|
class UpdaterMock < ::Updater
|
||||||
|
attr_accessor :diff
|
||||||
|
|
||||||
def initialize(*)
|
def initialize(*)
|
||||||
super
|
super
|
||||||
@outputs = Hash.new { |h, k| h[k] = [] }
|
@outputs = Hash.new { |h, k| h[k] = [] }
|
||||||
@ -51,12 +53,12 @@ class UpdaterTests < Homebrew::TestCase
|
|||||||
|
|
||||||
def perform_update(diff_output="")
|
def perform_update(diff_output="")
|
||||||
HOMEBREW_REPOSITORY.cd do
|
HOMEBREW_REPOSITORY.cd do
|
||||||
|
@updater.diff = diff_output
|
||||||
@updater.in_repo_expect("git checkout -q master")
|
@updater.in_repo_expect("git checkout -q master")
|
||||||
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "1234abcd")
|
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "1234abcd")
|
||||||
@updater.in_repo_expect("git config core.autocrlf false")
|
@updater.in_repo_expect("git config core.autocrlf false")
|
||||||
@updater.in_repo_expect("git pull -q origin refs/heads/master:refs/remotes/origin/master")
|
@updater.in_repo_expect("git pull -q origin refs/heads/master:refs/remotes/origin/master")
|
||||||
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef")
|
@updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef")
|
||||||
@updater.in_repo_expect("git diff-tree -r --name-status --diff-filter=AMD 1234abcd 3456cdef", diff_output)
|
|
||||||
@updater.pull!
|
@updater.pull!
|
||||||
@report.update(@updater.report)
|
@report.update(@updater.report)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user