Class: Git::Pr::Release::PullRequest
- Inherits:
-
Object
- Object
- Git::Pr::Release::PullRequest
show all
- Extended by:
- Util
- Includes:
- Util
- Defined in:
- lib/git/pr/release/pull_request.rb
Constant Summary
Constants included
from Util
Util::DEFAULT_PR_TEMPLATE
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Util
build_pr_title_and_body, dump_result_as_json, git, git_config, git_config_set, host_and_repository_and_scheme, merge_pr_body, obtain_token!, request_authorization, say
Constructor Details
Returns a new instance of PullRequest.
9
10
11
|
# File 'lib/git/pr/release/pull_request.rb', line 9
def initialize(pr)
@pr = pr
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
55
56
57
|
# File 'lib/git/pr/release/pull_request.rb', line 55
def method_missing(name, *args, &block)
@pr.public_send name, *args, &block
end
|
Instance Attribute Details
#pr ⇒ Object
Returns the value of attribute pr.
7
8
9
|
# File 'lib/git/pr/release/pull_request.rb', line 7
def pr
@pr
end
|
Class Method Details
.mention_type ⇒ Object
51
52
53
|
# File 'lib/git/pr/release/pull_request.rb', line 51
def self.mention_type
@mention_type ||= (ENV.fetch('GIT_PR_RELEASE_MENTION') { git_config('mention') } || 'default')
end
|
Instance Method Details
#html_link ⇒ Object
21
22
23
|
# File 'lib/git/pr/release/pull_request.rb', line 21
def html_link
pr.rels[:html].href
end
|
#mention ⇒ Object
29
30
31
32
|
# File 'lib/git/pr/release/pull_request.rb', line 29
def mention
mention = target_user_login_names.map { |login_name| "@#{login_name}" }.join(" ")
mention.empty? ? "" : " #{mention}"
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
59
60
61
|
# File 'lib/git/pr/release/pull_request.rb', line 59
def respond_to_missing?(name, include_private = false)
@pr.respond_to?(name, include_private)
end
|
#target_user_login_names ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/git/pr/release/pull_request.rb', line 34
def target_user_login_names
case PullRequest.mention_type
when 'author'
pr.user ? [pr.user.login] : []
else
if pr.assignees&.any? && pr.assignees.length > 1
pr.assignees.map(&:login)
elsif pr.assignee
[pr.assignee.login]
elsif pr.user
[pr.user.login]
else
[]
end
end
end
|
#to_checklist_item(print_title = false) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/git/pr/release/pull_request.rb', line 13
def to_checklist_item(print_title = false)
if print_title
"- [ ] ##{pr.number} #{pr.title}" + mention
else
"- [ ] ##{pr.number}" + mention
end
end
|
#to_hash ⇒ Object
25
26
27
|
# File 'lib/git/pr/release/pull_request.rb', line 25
def to_hash
{ :data => @pr.to_hash }
end
|