aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorXu Cheng2016-01-16 23:18:04 +0800
committerXu Cheng2016-01-17 14:52:14 +0800
commit80efb92c35463d1cc5c9dbc4684920ad687cbf20 (patch)
tree00c346f56d7705adc1bb74ec21716fcdf6d5d39e /Library/Homebrew
parentd4c7dedf1246e31daca2aa9be22f8f6e4a6c528f (diff)
downloadbrew-80efb92c35463d1cc5c9dbc4684920ad687cbf20.tar.bz2
FormulaVersion: support max depth
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/formula_versions.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb
index 9c0e97aa3..a60242d85 100644
--- a/Library/Homebrew/formula_versions.rb
+++ b/Library/Homebrew/formula_versions.rb
@@ -9,17 +9,19 @@ class FormulaVersions
attr_reader :name, :path, :repository, :entry_name
- def initialize(formula)
+ def initialize(formula, options = {})
@name = formula.name
@path = formula.path
@repository = formula.tap.path
@entry_name = @path.relative_path_from(repository).to_s
+ @max_depth = options[:max_depth]
end
def rev_list(branch)
repository.cd do
+ depth = 0
Utils.popen_read("git", "rev-list", "--abbrev-commit", "--remove-empty", branch, "--", entry_name) do |io|
- yield io.readline.chomp until io.eof?
+ yield io.readline.chomp until io.eof? || (@max_depth && (depth += 1) > @max_depth)
end
end
end