From e04a463f11d06ca5b6ef8142714ee651cb161815 Mon Sep 17 00:00:00 2001 From: Vlad Shablinsky Date: Tue, 13 Oct 2015 18:40:31 +0300 Subject: [PATCH] update: allow updating from local branch Closes Homebrew/homebrew#44893. Signed-off-by: Mike McQuaid --- Library/Homebrew/cmd/update.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Library/Homebrew/cmd/update.rb b/Library/Homebrew/cmd/update.rb index b50348bcfe..4e29221ac4 100644 --- a/Library/Homebrew/cmd/update.rb +++ b/Library/Homebrew/cmd/update.rb @@ -216,6 +216,20 @@ class Updater @initial_branch = "" end + # Used for testing purposes, e.g., for testing formula migration after + # renaming it in the currently checked-out branch. To test run + # "brew update --simulate-from-current-branch" + if ARGV.include?("--simulate-from-current-branch") + @initial_revision = `git rev-parse -q --verify #{@upstream_branch}`.chomp + @current_revision = read_current_revision + begin + safe_system "git", "merge-base", "--is-ancestor", @initial_revision, @current_revision + rescue ErrorDuringExecution + odie "Your HEAD is not a descendant of '#{@upstream_branch}'." + end + return + end + if @initial_branch != @upstream_branch && !@initial_branch.empty? safe_system "git", "checkout", @upstream_branch, *quiet end