Class: Metafrazo::Git
- Inherits:
-
Object
- Object
- Metafrazo::Git
- Defined in:
- lib/metafrazo/git.rb
Instance Method Summary collapse
- #add_label(label) ⇒ Object
- #comment(comment) ⇒ Object
-
#initialize(token, payload, repo = nil) ⇒ Git
constructor
A new instance of Git.
- #master_branch ⇒ Object
- #remote_origin ⇒ Object
- #repo_name ⇒ Object
- #sha ⇒ Object
Constructor Details
#initialize(token, payload, repo = nil) ⇒ Git
Returns a new instance of Git.
6 7 8 9 10 |
# File 'lib/metafrazo/git.rb', line 6 def initialize(token, payload, repo=nil) @pull_request = payload["pull_request"] @token = token @repo = repo end |
Instance Method Details
#add_label(label) ⇒ Object
16 17 18 |
# File 'lib/metafrazo/git.rb', line 16 def add_label(label) client.add_labels_to_an_issue(repo_name, issue_id, ["translations"]) end |
#comment(comment) ⇒ Object
12 13 14 |
# File 'lib/metafrazo/git.rb', line 12 def comment(comment) client.add_comment(repo_name, issue_id, comment) end |
#master_branch ⇒ Object
32 33 34 35 36 |
# File 'lib/metafrazo/git.rb', line 32 def master_branch @master_branch ||= begin (@repo && @repo[:base_branch]) || "master" end end |
#remote_origin ⇒ Object
20 21 22 |
# File 'lib/metafrazo/git.rb', line 20 def remote_origin "https://#{@token}:[email protected]/#{repo_name}.git" end |
#repo_name ⇒ Object
24 25 26 |
# File 'lib/metafrazo/git.rb', line 24 def repo_name @pull_request["head"]["repo"]["full_name"] end |
#sha ⇒ Object
28 29 30 |
# File 'lib/metafrazo/git.rb', line 28 def sha @pull_request["head"]["sha"] end |