aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Library/Homebrew/cmd/fetch.rb7
-rw-r--r--Library/Homebrew/formula.rb9
-rw-r--r--Library/Homebrew/formula_installer.rb8
-rw-r--r--Library/Homebrew/test/test_bottle_hooks.rb1
4 files changed, 23 insertions, 2 deletions
diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb
index 5ac41a4d3..171218294 100644
--- a/Library/Homebrew/cmd/fetch.rb
+++ b/Library/Homebrew/cmd/fetch.rb
@@ -32,6 +32,13 @@ module Homebrew
def fetch_bottle? f
return true if ARGV.force_bottle? && f.bottle
return false unless f.bottle && f.pour_bottle?
+ if f.file_modified?
+ filename = f.path.to_s.gsub("#{HOMEBREW_PREFIX}/", "")
+ opoo "Formula file is modified!"
+ puts "Fetching source because #{filename} has local changes"
+ puts "To fetch the bottle instead, run with --force-bottle"
+ return false
+ end
return false if ARGV.build_from_source? || ARGV.build_bottle?
return false unless f.bottle.compatible_cellar?
return true
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb
index bf11af009..fc378b819 100644
--- a/Library/Homebrew/formula.rb
+++ b/Library/Homebrew/formula.rb
@@ -601,6 +601,14 @@ class Formula
s << ") #{path}>"
end
+ def file_modified?
+ return false unless which("git")
+ path.parent.cd do
+ diff = Utils.popen_read("git", "diff", "origin/master", "--", "#{path}")
+ !diff.empty? && $?.exitstatus == 0
+ end
+ end
+
# Standard parameters for CMake builds.
# Setting CMAKE_FIND_FRAMEWORK to "LAST" tells CMake to search for our
# libraries before trying to utilize Frameworks, many of which will be from
@@ -1187,4 +1195,3 @@ class Formula
end
end
end
-
diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb
index 23f920d23..a6264ee62 100644
--- a/Library/Homebrew/formula_installer.rb
+++ b/Library/Homebrew/formula_installer.rb
@@ -62,7 +62,7 @@ class FormulaInstaller
bottle = formula.bottle
return true if force_bottle? && bottle
- return false if build_from_source? || build_bottle? || interactive?
+ return false if build_from_source? || build_bottle? || interactive? || formula.file_modified?
return false unless options.empty?
return true if formula.local_bottle_path
@@ -180,6 +180,12 @@ class FormulaInstaller
build_bottle_preinstall if build_bottle?
unless @poured_bottle
+ if formula.file_modified?
+ filename = formula.path.to_s.gsub("#{HOMEBREW_PREFIX}/", "")
+ opoo "Formula file is modified!"
+ puts "Building from source because #{filename} has local changes"
+ puts "To install from a bottle instead, run with --force-bottle"
+ end
compute_and_install_dependencies if @pour_failed and not ignore_deps?
build
clean
diff --git a/Library/Homebrew/test/test_bottle_hooks.rb b/Library/Homebrew/test/test_bottle_hooks.rb
index 92dca6dff..0b6c031bf 100644
--- a/Library/Homebrew/test/test_bottle_hooks.rb
+++ b/Library/Homebrew/test/test_bottle_hooks.rb
@@ -7,6 +7,7 @@ class BottleHookTests < Homebrew::TestCase
def bottle; end
def local_bottle_path; end
def some_random_method; true; end
+ def file_modified?; end
end
def setup