Skip to content

Instantly share code, notes, and snippets.

@copiousfreetime
Last active January 8, 2016 18:24
Show Gist options
  • Save copiousfreetime/97af58dfc8a693cbf835 to your computer and use it in GitHub Desktop.
Save copiousfreetime/97af58dfc8a693cbf835 to your computer and use it in GitHub Desktop.
A quick script to open the next issue in a repo
#!/usr/bin/env ruby
require 'bundler/inline'
gemfile(true) do
source 'https://rubygems.org'
gem 'octokit', '~> 4.2'
gem 'trollop', '~> 2.1'
gem 'launchy', '~> 2.4'
gem 'netrc', '~> 0.11'
end
require 'trollop'
require 'octokit'
require 'launchy'
require 'netrc'
SORT_BY = %w[ created updated comments ]
SORT_DIRECTION = %w[ asc desc ]
opts = Trollop::options do
opt :repo, "Github Repo", :default => "rubygems/rubygems"
opt :labels, "Label(s) to query", :default => %w[ triage ]
opt :sort, "Sort by #{SORT_BY.join(', ')}", :default => "created"
opt :direction, "Sort direction #{SORT_DIRECTION.join(', ')}", :default => "asc"
end
Trollop::die "Invalid sort column `#{opts[:sort]}`, must be one of #{SORT_BY.join(', ')}" unless SORT_BY.include?(opts[:sort])
Trollop::die "Invalid sort direction `#{opts[:direction]}`, must be one of #{SORT_DIRECTION.join(', ')}" unless SORT_DIRECTION.include?(opts[:direction])
repo_name = opts[:repo]
query_options = { :labels => opts[:labels].join(", "),
:sort => opts[:sort],
:direction => opts[:direction] }
# Octokit.auto_paginate = true # if you want to get them all
client = Octokit::Client.new(:netrc => true)
issues = client.list_issues(repo_name, query_options)
triage_me = issues.first
Launchy.open(triage_me.html_url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment