class Github
Github
API wrapper
Public Class Methods
make_class(name)
click to toggle source
# File lib/straight_line/common/github.rb, line 14 def self.make_class(name) class << self self end.instance_eval do define_method name do |*args| instance.send name, *args end end end
new()
click to toggle source
# File lib/straight_line/common/github.rb, line 10 def initialize @client = nil end
Public Instance Methods
client()
click to toggle source
# File lib/straight_line/common/github.rb, line 38 def client return @client if @client @client = Octokit::Client.new netrc: true, auto_paginate: true end
create_pull_request(branch, title, body)
click to toggle source
# File lib/straight_line/common/github.rb, line 44 def create_pull_request(branch, title, body) repo = repo_name client.create_pull_request repo, 'master', "#{github_login}:#{branch}", title, body end
ensure_logged_in()
click to toggle source
# File lib/straight_line/common/github.rb, line 34 def ensure_logged_in raise UserError, 'Must be logged in first' unless @client end
github_login()
click to toggle source
# File lib/straight_line/common/github.rb, line 57 def github_login client.user.login end
list_repos()
click to toggle source
# File lib/straight_line/common/github.rb, line 26 def list_repos @client.repositories query: { type: 'private' } end
login()
click to toggle source
# File lib/straight_line/common/github.rb, line 24 def login; end
pull_request_for_feature(feature)
click to toggle source
# File lib/straight_line/common/github.rb, line 67 def pull_request_for_feature(feature) prs = pull_requests prs.find do |p| p.head.ref == feature && p.head.user.login == Github.github_login && p.base.ref == 'master' end end
pull_requests()
click to toggle source
# File lib/straight_line/common/github.rb, line 62 def pull_requests client.pull_requests repo_name end
repo_name()
click to toggle source
# File lib/straight_line/common/github.rb, line 51 def repo_name cmd = GitCommands::Config.new('remote.origin.url') remote = cmd.run remote.match(%r{(git@github.com:)(.*/.*)\.git})[2] end
user()
click to toggle source
# File lib/straight_line/common/github.rb, line 30 def user @client.user end