class Gitdig::Commands::Pr::Team

Constants

REPO_REGEX

Public Class Methods

new(team_id, options) click to toggle source
# File lib/gitdig/commands/pr/team.rb, line 11
def initialize(team_id, options)
  @team_id = team_id
  @options = options
end

Public Instance Methods

execute(input: $stdin, output: $stdout) click to toggle source
# File lib/gitdig/commands/pr/team.rb, line 16
def execute(input: $stdin, output: $stdout)
  issues = github_client.search_issues(
    search_str,
    sort: 'created', order: 'asc', per_page: 100
  )
  issues.items.each do |i|
    output.puts pr_output(i)
  end
end

Private Instance Methods

members(team_id) click to toggle source
# File lib/gitdig/commands/pr/team.rb, line 60
def members(team_id)
  github_client.team_members(team_id)
end
org() click to toggle source
# File lib/gitdig/commands/pr/team.rb, line 46
def org
  @org ||= @options[:organization] || configs.fetch(:org)
end
pr_output(pull) click to toggle source
# File lib/gitdig/commands/pr/team.rb, line 64
def pr_output(pull)
  repo = REPO_REGEX.match(pull.repository_url).to_s
  "* [#{pull.title}](#{pull.html_url}) <#{pull.state}>"\
    " #{repo}##{pull.number} @#{pull.user.login}"
end
search_str() click to toggle source
# File lib/gitdig/commands/pr/team.rb, line 34
def search_str
  @search_str ||=
    begin
      author_str = members(team).map { |mem| "author:#{mem.login}" }.join(' ')
      search_str = "type:pr #{author_str}"
      search_str = "#{search_str} created:#{@options[:created]}" if @options[:created]
      search_str = "#{search_str} org:#{org}" if org

      search_str
    end
end
team() click to toggle source
# File lib/gitdig/commands/pr/team.rb, line 28
def team
  @team = @team_id || prompt.select('Choose a team to get pull requests') do |menu|
    teams.each { |t| menu.choice "#{t.name} (#{t.id})", t.id }
  end
end
teams() click to toggle source
# File lib/gitdig/commands/pr/team.rb, line 50
def teams
  @teams ||= if @options[:team]
               github_client.child_teams(@options[:team])
             elsif @options[:organization]
               github_client.organization_teams(@options[:organization])
             elsif (org = configs.fetch(:org))
               github_client.organization_teams(org)
             end
end