class GithubFlowCli::API
Public Class Methods
create_issue(title, body = nil, options = {})
click to toggle source
TODO: explicify options :assignee (String) — User login. :milestone (Integer) — Milestone number. :labels TODO: keywordify parameters
# File lib/github_flow_cli/api.rb, line 54 def create_issue(title, body = nil, options = {}) @client.create_issue(Local.repo, title, body, options) end
create_pr(base: "master", title: nil, body: nil)
click to toggle source
TODO: other options
# File lib/github_flow_cli/api.rb, line 59 def create_pr(base: "master", title: nil, body: nil) branch_name = Local.git.current_branch issue_number = Config.branch_issue_map[branch_name] if issue_number issue = API.issue(Local.repo, issue_number) title ||= issue.title body ||= issue.body end unless Local.git.branches.remote.find { |b| b.name == branch_name } # TODO: custom default remote puts "no remote branch found, creating remote branch..." Local.git.config("branch.#{branch_name}.remote", 'origin') Local.git.config("branch.#{branch_name}.merge", "refs/heads/#{branch_name}") end # TODO: custom default remote puts "git push..." Local.git.push('origin', branch_name) @client.create_pull_request(Local.repo, base, branch_name, title, body).tap do |pr| Config.link_pr_to_branch(pr, branch_name) end end
method_missing(method, *args, &block)
click to toggle source
delegate API
calls to Octokit::Client
Calls superclass method
# File lib/github_flow_cli/api.rb, line 39 def method_missing(method, *args, &block) if @client.respond_to?(method) define_singleton_method(method) do |*args, &block| @client.send(method, *args, &block) end return send(method, *args, &block) end super end
use_oauth_token(token)
click to toggle source
# File lib/github_flow_cli/api.rb, line 28 def use_oauth_token(token) @client = Octokit::Client.new(access_token: token) end
valid?()
click to toggle source
# File lib/github_flow_cli/api.rb, line 32 def valid? !user[:login].nil? rescue Octokit::Unauthorized false end
Private Class Methods
app_name()
click to toggle source
# File lib/github_flow_cli/api.rb, line 83 def app_name "hubflow for #{`whoami`.strip}@#{`hostname`.strip}" end