Class: Metafrazo::Git

Inherits:
Object
  • Object
show all
Defined in:
lib/metafrazo/git.rb

Instance Method Summary collapse

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_branchObject



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_originObject



20
21
22
# File 'lib/metafrazo/git.rb', line 20

def remote_origin
  "https://#{@token}:[email protected]/#{repo_name}.git"
end

#repo_nameObject



24
25
26
# File 'lib/metafrazo/git.rb', line 24

def repo_name
  @pull_request["head"]["repo"]["full_name"]
end

#shaObject



28
29
30
# File 'lib/metafrazo/git.rb', line 28

def sha
  @pull_request["head"]["sha"]
end