Module: Gith::Github

Included in:
Deliver, Discuss, Finish, Review
Defined in:
lib/gith/adapters/github.rb

Constant Summary collapse

PENDING_REVIEW =
'review-pending'
PASSED_REVIEW =
'review-passed'
REVIEW_ME =
'bot review me '
WIP =
'WIP'
DNM =
'do-not-merge'

Instance Method Summary collapse

Instance Method Details

#add_comment(pull, comment) ⇒ Object



54
55
56
# File 'lib/gith/adapters/github.rb', line 54

def add_comment(pull, comment)
  github.add_comment $repo, pull.number, comment
end

#githubObject

$repo loaded in init.rb



14
15
16
# File 'lib/gith/adapters/github.rb', line 14

def github
  @github ||= Octokit::Client.new(access_token: config[:github_token])
end

#label_pull_request(pull, *labels) ⇒ Object



36
37
38
39
40
# File 'lib/gith/adapters/github.rb', line 36

def label_pull_request(pull, *labels)
  unless labels_for(pull).map(&:name).sort == labels.sort
    github.add_labels_to_an_issue $repo, pull.number, labels
  end
end

#labels_for(pull) ⇒ Object



42
43
44
# File 'lib/gith/adapters/github.rb', line 42

def labels_for(pull)
  github.labels_for_issue $repo, pull.number
end

#open_pull_request(branch, title, body) ⇒ Object



18
19
20
21
22
# File 'lib/gith/adapters/github.rb', line 18

def open_pull_request(branch, title, body)
  @pull_request = github.create_pull_request($repo, 'master', branch, title, body)
  Launchy.open @pull_request.html_url
  @pull_request
end

#pull_for(branch) ⇒ Object



24
25
26
# File 'lib/gith/adapters/github.rb', line 24

def pull_for(branch)
  pull_requests.detect { |pr| pr.head.ref == branch }
end

#pull_request(id) ⇒ Object



32
33
34
# File 'lib/gith/adapters/github.rb', line 32

def pull_request(id)
  github.pull_request $repo, id
end

#pull_requestsObject



28
29
30
# File 'lib/gith/adapters/github.rb', line 28

def pull_requests
  github.pull_requests $repo
end

#remove_label(pull, label) ⇒ Object



50
51
52
# File 'lib/gith/adapters/github.rb', line 50

def remove_label(pull, label)
  github.remove_label $repo, pull.number, label
end

#remove_labels(pull) ⇒ Object



46
47
48
# File 'lib/gith/adapters/github.rb', line 46

def remove_labels(pull)
  github.remove_all_labels $repo, pull.number
end