bin/git-latest-pushes in git-whistles-0.8.1 vs bin/git-latest-pushes in git-whistles-0.8.2

- old
+ new

@@ -18,15 +18,16 @@ def main(args) super parse_args!(args) - results = `git for-each-ref --sort=-committerdate --count=#{options.results} refs/remotes/origin/#{options.pattern} --format='[%(committerdate:relative)] (%(authorname)) %(refname)'` + results = `git for-each-ref --sort=-committerdate --format='[%(committerdate:relative)] (%(authorname)) %(refname)' refs/remotes/origin/ | grep '#{options.pattern}'` results = results.split("\n") if results.any? - puts "Latest #{ [results.length, options.results].min } pushed branches:" + results = results.slice(0, [results.length, options.nr_results].min) + puts "Latest #{ results.length } pushed branches:" results.each do |branch| puts branch.gsub('refs/remotes/origin/', '') end else @@ -34,11 +35,11 @@ end end def defaults { - :results => 20, + :nr_results => 20, :pattern => '' } end def option_parser @@ -47,10 +48,10 @@ Returns the list of latest pushed branches on origin Usage: git latest-pushes [-n NR_RESULTS] [-p PATTERN] } op.on("-n", "--n [NR_RESULTS]", "Number of results to display, defaults to 20") do |n| - options.nr_results = n + options.nr_results = n.to_i end op.on("-p", "--p [PATTERN]", "Pattern to lookup. Eg. -p my-team-name") do |pattern| options.pattern = pattern end