update: use git stash silently.

There's been a few issues where users have been confused about these
errors. They may have modified stuff but we probably don't care about
telling them that unless we're debugging other issues.

Closes Homebrew/homebrew#45373.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
Mike McQuaid 2015-10-26 15:00:59 -06:00
parent be1ac34117
commit 8ea9903a99

View File

@ -196,18 +196,17 @@ class Updater
def initialize(repository) def initialize(repository)
@repository = repository @repository = repository
@stashed = false @stashed = false
@quiet_args = []
@quiet_args << "--quiet" unless ARGV.verbose?
end end
def pull!(options = {}) def pull!(options = {})
quiet = []
quiet << "--quiet" unless ARGV.verbose?
unless system "git", "diff", "--quiet" unless system "git", "diff", "--quiet"
unless options[:silent] if ARGV.verbose?
puts "Stashing your changes:" puts "Stashing your changes:"
system "git", "status", "--short", "--untracked-files" system "git", "status", "--short", "--untracked-files"
end end
safe_system "git", "stash", "save", "--include-untracked", *quiet safe_system "git", "stash", "save", "--include-untracked", *@quiet_args
@stashed = true @stashed = true
end end
@ -242,7 +241,7 @@ class Updater
end end
if @initial_branch != @upstream_branch && !@initial_branch.empty? if @initial_branch != @upstream_branch && !@initial_branch.empty?
safe_system "git", "checkout", @upstream_branch, *quiet safe_system "git", "checkout", @upstream_branch, *@quiet_args
end end
@initial_revision = read_current_revision @initial_revision = read_current_revision
@ -253,7 +252,7 @@ class Updater
args = ["pull"] args = ["pull"]
args << "--ff" args << "--ff"
args << ((ARGV.include? "--rebase") ? "--rebase" : "--no-rebase") args << ((ARGV.include? "--rebase") ? "--rebase" : "--no-rebase")
args += quiet args += @quiet_args
args << "origin" args << "origin"
# the refspec ensures that the default upstream branch gets updated # the refspec ensures that the default upstream branch gets updated
args << "refs/heads/#{@upstream_branch}:refs/remotes/origin/#{@upstream_branch}" args << "refs/heads/#{@upstream_branch}:refs/remotes/origin/#{@upstream_branch}"
@ -263,12 +262,12 @@ class Updater
@current_revision = read_current_revision @current_revision = read_current_revision
if @initial_branch != "master" && !@initial_branch.empty? if @initial_branch != "master" && !@initial_branch.empty?
safe_system "git", "checkout", @initial_branch, *quiet safe_system "git", "checkout", @initial_branch, *@quiet_args
end end
if @stashed if @stashed
safe_system "git", "stash", "pop", *quiet safe_system "git", "stash", "pop", *@quiet_args
unless options[:silent] if ARGV.verbose?
puts "Restored your changes:" puts "Restored your changes:"
system "git", "status", "--short", "--untracked-files" system "git", "status", "--short", "--untracked-files"
end end
@ -282,7 +281,8 @@ class Updater
if $?.signaled? && $?.termsig == 2 # SIGINT if $?.signaled? && $?.termsig == 2 # SIGINT
safe_system "git", "checkout", @initial_branch unless @initial_branch.empty? safe_system "git", "checkout", @initial_branch unless @initial_branch.empty?
safe_system "git", "reset", "--hard", @initial_revision safe_system "git", "reset", "--hard", @initial_revision
safe_system "git", "stash", "pop" if @stashed safe_system "git", "stash", "pop", *@quiet_args if @stashed
@stashed = false
end end
end end