diff options
| author | Martin Afanasjew | 2015-08-19 16:02:24 +0200 |
|---|---|---|
| committer | Mike McQuaid | 2015-08-27 13:53:28 +0100 |
| commit | 1288e3110d5b59a3d49e8f0e01e7537235309ae9 (patch) | |
| tree | af4be8e18489a413ee86a28eb7d2e2cc288d06fc /Library | |
| parent | fc445d97d36d7d38d83853c0f9d4abaa27b343fa (diff) | |
| download | brew-1288e3110d5b59a3d49e8f0e01e7537235309ae9.tar.bz2 | |
update: always report changes to branch 'master'
If the user's working copy is *not* on the 'master' branch, the revision
recorded after the update to the 'master' branch is not the one of the
updated 'master' branch but that of whatever the user's current branch
is. This tends to be not very helpful.
This change records the revision *after* the update to the 'master'
branch, but *before* switching back to the user's current branch prior
to the update, effectively causing the report to show changes to the
'master' branch.
Closes Homebrew/homebrew#42074.
Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/update.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_updater.rb | 1 |
2 files changed, 10 insertions, 3 deletions
diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index 200f03979..83350988b 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -194,6 +194,8 @@ class Updater reset_on_interrupt { safe_system "git", *args } + @current_revision = read_current_revision + if @initial_branch != "master" && !@initial_branch.empty? safe_system "git", "checkout", @initial_branch, *quiet end @@ -206,8 +208,6 @@ class Updater end @stashed = false end - - @current_revision = read_current_revision end def reset_on_interrupt @@ -224,6 +224,8 @@ class Updater map = Hash.new { |h, k| h[k] = [] } if initial_revision && initial_revision != current_revision + wc_revision = read_current_revision + diff.each_line do |line| status, *paths = line.split src = paths.first @@ -239,7 +241,11 @@ class Updater file = repository.join(src) begin formula = Formulary.factory(file) - new_version = formula.pkg_version + new_version = if wc_revision == current_revision + formula.pkg_version + else + FormulaVersions.new(formula).formula_at_revision(@current_revision, &:pkg_version) + end old_version = FormulaVersions.new(formula).formula_at_revision(@initial_revision, &:pkg_version) next if new_version == old_version rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS => e diff --git a/Library/Homebrew/test/test_updater.rb b/Library/Homebrew/test/test_updater.rb index 9c3c02979..87e175ea3 100644 --- a/Library/Homebrew/test/test_updater.rb +++ b/Library/Homebrew/test/test_updater.rb @@ -64,6 +64,7 @@ class UpdaterTests < Homebrew::TestCase @updater.in_repo_expect("git pull --quiet origin refs/heads/master:refs/remotes/origin/master") @updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef") @updater.pull!(:silent => true) + @updater.in_repo_expect("git rev-parse -q --verify HEAD", "3456cdef") @report.update(@updater.report) assert_equal @updater.expected, @updater.called end |
