Class: Codebot::Formatters::Gitlab::NoteHook
Overview
Triggers on a Note Hook event
Instance Attribute Summary
#payload
Instance Method Summary
collapse
#abbreviate, #action, #ary_to_sentence, #closed?, #extract, #format_branch, #format_dangerous, #format_event, #format_hash, #format_number, #format_repository, #format_url, #format_user, #gitlab_action, #gitlab_closed?, #gitlab_opened?, #gitlab_repository_url, #gitlab_url, #initialize, #opened?, #prettify, #repository_url, #sanitize, #shorten_url, #url
Instance Method Details
#comment_body ⇒ Object
97
98
99
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 97
def comment_body
(:object_attributes, :note)
end
|
76
77
78
79
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 76
def commit_default_format
'[%<repository>s] %<sender>s commented on commit' \
' %<hash>s: %<summary>s'
end
|
#commit_id ⇒ Object
113
114
115
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 113
def commit_id
(:commit, :id)
end
|
#commit_summary ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 52
def commit_summary
commit_default_format % {
repository: format_repository(repository_name),
sender: format_user(sender_name),
hash: format_hash(commit_id),
summary: prettify(comment_body)
}
end
|
8
9
10
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 8
def format
["#{summary}: #{format_url url}"]
end
|
61
62
63
64
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 61
def issue_default_format
'[%<repository>s] %<sender>s commented on issue' \
' #%<number>s: %<summary>s'
end
|
#issue_number ⇒ Object
109
110
111
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 109
def issue_number
(:issue, :iid)
end
|
#issue_summary ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 25
def issue_summary
issue_default_format % {
repository: format_repository(repository_name),
sender: format_user(sender_name),
number: issue_number,
summary: prettify(comment_body)
}
end
|
71
72
73
74
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 71
def merge_request_default_format
'[%<repository>s] %<sender>s commented on merge request' \
' \'%<mr>s\': %<summary>s'
end
|
#merge_request_summary ⇒ Object
43
44
45
46
47
48
49
50
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 43
def merge_request_summary
merge_request_default_format % {
repository: format_repository(repository_name),
sender: format_user(sender_name),
mr: merge_request_title,
summary: prettify(comment_body)
}
end
|
#merge_request_title ⇒ Object
105
106
107
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 105
def merge_request_title
(:merge_request, :title)
end
|
#note_type ⇒ Object
81
82
83
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 81
def note_type
(:object_attributes, :noteable_type)
end
|
#repository_name ⇒ Object
85
86
87
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 85
def repository_name
(:project, :path_with_namespace)
end
|
#sender_name ⇒ Object
89
90
91
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 89
def sender_name
(:user, :name)
end
|
66
67
68
69
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 66
def snippet_default_format
'[%<repository>s] %<sender>s commented on code snippet' \
' \'%<snippet>s\': %<summary>s'
end
|
#snippet_summary ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 34
def snippet_summary
snippet_default_format % {
repository: format_repository(repository_name),
sender: format_user(sender_name),
snippet: snippet_title,
summary: prettify(comment_body)
}
end
|
#snippet_title ⇒ Object
101
102
103
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 101
def snippet_title
(:snippet, :title)
end
|
#summary ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 12
def summary
case note_type
when 'Issue'
issue_summary
when 'Snippet'
snippet_summary
when 'MergeRequest'
merge_request_summary
when 'Commit'
commit_summary
end
end
|
#summary_url ⇒ Object
93
94
95
|
# File 'lib/codebot/formatters/gitlab_note_hook.rb', line 93
def summary_url
(:object_attributes, :url)
end
|