Class: GithubPulley::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/github_pulley/base.rb

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



3
4
5
# File 'lib/github_pulley/base.rb', line 3

def initialize
  @octokit = Octokit::Client.new(:login => github_user, :oauth_token => github_token)
end

Instance Method Details

#attach_pull_request_to_issue(issue, opts = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/github_pulley/base.rb', line 14

def attach_pull_request_to_issue(issue, opts={})
  opts = {
    :base => 'master',
    :head => "#{origin_user}:#{current_branch}",
    :branch => current_branch
  }.merge(opts)
  p opts
  puts "Pushing to #{opts[:branch]} on 'origin'"
  `git push origin #{opts[:branch]}`
  pull_to = forked_from || origin_repo
  # @octokit.create_pull_request_for_issue(repo, base, head, issue, options={})
  # Returns nil if successfull
  @octokit.create_pull_request_for_issue(pull_to, opts[:base], opts[:head], issue)

  issue_details = @octokit.issue(repo, issue)
  print_issue(issue_details, "Attached to")
end

#create_pull_request(title, body = '', opts = {}) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/github_pulley/base.rb', line 32

def create_pull_request(title, body='', opts={})
  opts = {
    :base => 'master',
    :head => "#{origin_user}:#{current_branch}",
    :branch => current_branch
  }.merge(opts)
  puts "Pushing to #{opts[:branch]} on 'origin'"
  `git push origin #{opts[:branch]}`
  pull_to = forked_from || origin_repo
  @octokit.create_pull_request(pull_to, opts[:base], opts[:head], title, body)
  # Returns nil if successfull
  puts "Created new pull request"
end

#get_open_issues(opts = {}) ⇒ Object



7
8
9
10
11
12
# File 'lib/github_pulley/base.rb', line 7

def get_open_issues(opts={})
  # Listing by assignee seems to be broken
  all_open_issues.each do |issue|
    print_issue(issue, "")
  end
end