Class: Lita::Extensions::GitHubWebHooksCore::Hooks::PullRequest
- Inherits:
-
Hook
- Object
- Hook
- Lita::Extensions::GitHubWebHooksCore::Hooks::PullRequest
show all
- Includes:
- RepoHooks
- Defined in:
- lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb
Instance Attribute Summary
Attributes inherited from Hook
#payload
Instance Method Summary
collapse
Methods included from RepoHooks
#access_token, #client, #repo, #repository
Methods inherited from Hook
#initialize
Instance Method Details
#action ⇒ Object
55
56
57
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 55
def action
payload["action"]
end
|
#attributes ⇒ Object
75
76
77
78
79
80
81
82
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 75
def attributes
{requester: requester,
pr: pr,
target_branch: target_branch,
candidate_branch: candidate_branch,
url: url
}
end
|
#candidate_branch ⇒ Object
39
40
41
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 39
def candidate_branch
pr["head"]["label"].split(":").last
end
|
#closed? ⇒ Boolean
67
68
69
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 67
def closed?
action == "closed"
end
|
#merged? ⇒ Boolean
71
72
73
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 71
def merged?
closed? && pr["merged"]
end
|
#number ⇒ Object
31
32
33
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 31
def number
pr["number"]
end
|
#opened? ⇒ Boolean
59
60
61
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 59
def opened?
action == "opened"
end
|
#pr ⇒ Object
23
24
25
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 23
def pr
payload["pull_request"]
end
|
#ref ⇒ Object
47
48
49
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 47
def ref
pr["head"]["ref"]
end
|
#requester ⇒ Object
19
20
21
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 19
def requester
payload["sender"]
end
|
#set_status(status, options = {}) ⇒ Object
84
85
86
87
88
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 84
def set_status(status, options={})
return if status.nil? || options[:target_url].nil?
options[:context] ||= "lita"
client.create_status(self.repo, self.sha, status, options)
end
|
#sha ⇒ Object
51
52
53
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 51
def sha
pr["head"]["sha"]
end
|
#synchronized? ⇒ Boolean
63
64
65
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 63
def synchronized?
action == "synchronize"
end
|
#target_branch ⇒ Object
35
36
37
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 35
def target_branch
pr["base"]["label"].split(":").last
end
|
#title ⇒ Object
27
28
29
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 27
def title
pr["title"]
end
|
#to_s ⇒ Object
90
91
92
93
94
95
96
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 90
def to_s
if merged?
"[#{self.repo}] #{self.requester["login"]} has merged #{candidate_branch} to #{target_branch} and #{self.action} pull request ##{self.number}: #{self.title}"
else
"[#{self.repo}] #{self.requester["login"]} has #{self.action} pull request ##{self.number}: #{self.title}: #{self.url}"
end
end
|
#url ⇒ Object
43
44
45
|
# File 'lib/lita/extensions/github_web_hooks_core/hooks/pull_request.rb', line 43
def url
pr["html_url"]
end
|