Sha256: d83de065a59268bdaa635d4e15d6dba35941a3700c4f9c674204403ce8de6079
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require 'octokit' module Git class Pr class GitHub class Failed < StandardError; end def initialize(git_properties) @git = git_properties Octokit.configure do |c| c.login = @git.login c.password = @git.api_token end end def list_pull_requests(profile, mine) if profile repositories = @git.repository_profile(profile) else repositories = [@git.repository] end [].tap do |prs| repositories.flatten.uniq.each do |repo| pull_requests = Octokit.pull_requests(repo, 'open') if mine prs << pull_requests.select { |pr| pr.user.login == @git.login } else prs << pull_requests end end end.flatten end def submit_pull_request(title, message) response = Octokit.create_pull_request(@git.repository, @git.base_branch, @git.current_branch, title, message) response.state == 'open' ? response : raise(Failed, response.state) rescue Octokit::UnprocessableEntity => e message = e.message.match(/message: (.*)/)[1].sub(/ \/\/.*/, '') raise Failed, message end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
git-pr-0.0.2 | lib/git/pr/github.rb |