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
52
53
54
|
# File 'lib/git/pr/release/pull_request.rb', line 52
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
48
49
50
|
# File 'lib/git/pr/release/pull_request.rb', line 48
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/git/pr/release/pull_request.rb', line 29
def mention
mention = case PullRequest.mention_type
when 'author'
pr.user ? "@#{pr.user.login}" : nil
else
if pr.assignees&.any? && pr.assignees.length > 1
pr.assignees.map { |assignee| "@#{assignee.login}" }.join(" ")
elsif pr.assignee
"@#{pr.assignee.login}"
elsif pr.user
"@#{pr.user.login}"
else
nil
end
end
mention ? " #{mention}" : ""
end
|
#respond_to_missing?(name, include_private = false) ⇒ Boolean
56
57
58
|
# File 'lib/git/pr/release/pull_request.rb', line 56
def respond_to_missing?(name, include_private = false)
@pr.respond_to?(name, include_private)
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
|