Sha256: a9eab74dbcbfa4e26ee56f6938270fdccba5fd206197edded9dabe35c7b72db9
Contents?: true
Size: 1.47 KB
Versions: 16
Compression:
Stored size: 1.47 KB
Contents
#!/usr/bin/env ruby # encoding: UTF-8 # # git-latest-pushes -- # # List of latest pushed branches on origin # require 'rubygems' require 'optparse' require 'term/ansicolor' require 'git-whistles/app' class App < Git::Whistles::App def initialize super end def main(args) super parse_args!(args) 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? 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 puts "no results..." end end def defaults { :nr_results => 20, :pattern => '' } end def option_parser @option_parser ||= OptionParser.new do |op| op.banner = %Q{ 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.to_i end op.on("-p", "--p [PATTERN]", "Pattern to lookup. Eg. -p my-team-name") do |pattern| options.pattern = pattern end op.on_tail("-h", "--help", "Show this message") do puts op exit end end end end App.run!
Version data entries
16 entries across 16 versions & 1 rubygems