Created
March 19, 2014 01:00
-
-
Save tpope/9633483 to your computer and use it in GitHub Desktop.
Add a gmail label to all closed issues where I the tpope last commented
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'gmail' | |
require 'github_api' | |
require 'netrc' | |
require 'pry' | |
netrc = Netrc.read | |
github = Github.new(basic_auth: netrc['api.github.com'].join(':')) | |
Gmail.new(*netrc['imap.gmail.com']) do |gmail| | |
gmail.inbox.emails(from: 'github.com').each do |message| | |
begin | |
begin | |
_, owner, repo, type, number = *message.message_id.split(%r{[</@]}) | |
rescue NoMethodError | |
# message removed from inbox since search began (?) | |
next | |
end | |
next unless %w(issues pull).include?(type) | |
repo = 'vim-fireplace' if repo == 'vim-foreplay' | |
issue = github.issues.get(owner, repo, number) | |
comment = github.issues.comments.list(owner, repo, issue_id: number, sort: 'created', direction: 'desc').first | |
if issue.state == 'closed' && (!comment || comment.user.login == 'tpope') | |
puts [owner, repo, type, number].join('/') | |
message.star! # doesn't seem to work | |
message.label('Test') | |
end | |
rescue => e | |
puts e.message | |
binding.pry | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment