Sha256: 408ce78427b2bec80bf29acd17b1c819a6d191e97becf3f4a2a0d50e0836fec4

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

#!/usr/bin/env ruby
# encoding: UTF-8
#
# git-outstanding-features --
#
# List merged pull requests.
#
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)

    merges = `git log --merges --first-parent --oneline #{options.from} ^#{options.to} | grep 'Merge pull request'`
    return if merges.nil?

    output = []
    merges.lines.each do |merge|
      merge.match /(#\d+).*from (.*)/ 
      output << $1.strip + ' ' + $2.strip
    end

    puts options.oneline ? output.join(', ') : output
  end

  def defaults
    {
      :from    => 'origin/master',
      :to      => 'origin/production',
      :oneline => false
    }
  end

  def option_parser
    @option_parser ||= OptionParser.new do |op|
      op.banner = "Usage: git outstanding-features --from [FROM-BRANCH] --to [TO-BRANCH]"

      op.on("-f", "--from [BRANCH]", "From branch") do |from|
        options.from = from
      end

      op.on("-t", "--to [BRANCH]", "To branch") do |to|
        options.to = to
      end

      op.on("-o", "--oneline", "Output features in one line separated by spaces") do |oneline|
        options.oneline = true
      end

      op.on_tail("-h", "--help", "Show this message") do
        puts op
        exit
      end
    end
  end
end

App.run!

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
git-whistles-0.9.0 bin/git-outstanding-features
git-whistles-0.8.2 bin/git-outstanding-features