Sha256: 707307faf57b2baaf1f1743224b68fc75d04496856041504427088a275ebc667

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

#!/usr/bin/env ruby

require 'optparse'
require 'methadone'
require 'octokit'
require 'soopr.rb'

class String
  # colorization
  def colorize(color_code)
    "\e[#{color_code}m#{self}\e[0m"
  end

  def red
    colorize(31)
  end

  def green
    colorize(32)
  end

  def blue
    colorize(34)
  end
end

class App
  include Methadone::Main
  include Methadone::CLILogging

  main do |organisation, team|
    Octokit.configure do |c|
      c.netrc = true
    end

    debug "Starting to fetch teams for organisation '#{organisation}'"

    teams = Octokit.organization_teams organisation
    team_resource = teams.find{ |t| t.name == team}
    if team_resource.nil?
      exit_now! 1, "No team with name '#{team}' could be found"
    end

    debug "Starting to fetch repos for team '#{team}'"

    repos = Octokit.team_repositories(team_resource.id)
                .select{|r| r.open_issues_count > 0}


    if repos.empty?
      puts "No open pull requests found.".green
    else

      debug "Open pull requests for '#{team}':"

      repos.each do |repo|
        pull_requests = Octokit.pull_requests repo.id
        if pull_requests.size > 0 then
          puts "# #{repo.name}".red
          pull_requests.each do |pr|
            puts "- #{pr.title}: ".blue + "#{pr.html_url}\n\n".green
          end
        end
      end
    end
  end

  version Soopr::VERSION

  description 'List open pull requests of a Github team'

  arg :organisation, "Github organisation the team belongs to"
  arg :team, "Github team from which to list open pull requests"

  use_log_level_option :toggle_debug_on_signal => 'USR1'

  go!
end

Version data entries

3 entries across 2 versions & 1 rubygems

Version Path
soopr-0.1.2 bin/soopr
soopr-0.1.2 exe/soopr
soopr-0.1.1 bin/soopr