From 80efb92c35463d1cc5c9dbc4684920ad687cbf20 Mon Sep 17 00:00:00 2001 From: Xu Cheng Date: Sat, 16 Jan 2016 23:18:04 +0800 Subject: [PATCH] FormulaVersion: support max depth --- Library/Homebrew/formula_versions.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/formula_versions.rb b/Library/Homebrew/formula_versions.rb index 9c0e97aa3c..a60242d858 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