lita-gitlab 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/gitlab.rb +31 -19
- data/lita-gitlab.gemspec +1 -1
- data/locales/en.yml +7 -7
- data/spec/fixtures/system/project_created.json +1 -1
- data/spec/fixtures/web/{push.json → add_to_branch.json} +0 -0
- data/spec/fixtures/web/{issue.json → issue_opened.json} +0 -0
- data/spec/fixtures/web/{merge_request.json → merge_request_opened.json} +0 -0
- data/spec/lita/handlers/gitlab_spec.rb +15 -12
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fe86ceb0dfe52c83ef5012502e4698869f72646
|
4
|
+
data.tar.gz: dd8f9098dabb15d526bb59d809b56e8e639a8760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9729cb3159a9ff315949a108aad3ac882b687d40e86f097a7c452046192d1fad3d34d51dfe713b5212e431052f7df03ec3ef2213c43ce41ea4ac3ea2849fb2d0
|
7
|
+
data.tar.gz: 2859e810f328e5969efbe953611e6fc17f0772abe5b642db4d51ea2eaebca717ec63845ad0b1b64a3ce5c4d67a6cf8b6d9da0b73e691264fd89d019b0486a6cc
|
data/lib/lita/handlers/gitlab.rb
CHANGED
@@ -40,40 +40,52 @@ module Lita
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def system_message(data)
|
43
|
-
|
43
|
+
interpolate_message "system.#{data[:event_name]}", data
|
44
44
|
rescue
|
45
45
|
Lita.logger.warn "Error formatting message: #{data.inspect}"
|
46
46
|
end
|
47
47
|
|
48
48
|
def web_message(data)
|
49
49
|
if data.key? :object_kind
|
50
|
-
|
51
|
-
|
52
|
-
url = "#{Lita.config.handlers.gitlab.url}"
|
53
|
-
url += data[:project] ? "#{Lita.config.handlers.gitlab.group}/#{data[:project]}/merge_requests/#{data[:object_attributes][:iid]}" : "groups/#{Lita.config.handlers.gitlab.group}"
|
54
|
-
data[:object_attributes][:link] = "<#{url}|#{data[:object_attributes][:title]}>"
|
55
|
-
build_message "web.#{data[:object_kind]}.#{data[:object_attributes][:state]}", data[:object_attributes]
|
56
|
-
else
|
57
|
-
# Issue
|
58
|
-
build_message "web.#{data[:object_kind]}.#{data[:object_attributes][:state]}", data[:object_attributes]
|
59
|
-
end
|
50
|
+
# Merge has target branch
|
51
|
+
(data[:object_attributes].key? :target_branch) ? build_merge_message(data) : build_issue_message(data)
|
60
52
|
else
|
61
53
|
# Push has no object kind
|
62
|
-
|
63
|
-
data[:link] = "<#{data[:repository][:homepage]}|#{data[:repository][:name]}>"
|
64
|
-
if data[:before] =~ /^0+$/
|
65
|
-
build_message 'web.push.new_branch', data
|
66
|
-
else
|
67
|
-
build_message 'web.push.add_to_branch', data
|
68
|
-
end
|
54
|
+
build_branch_message(data)
|
69
55
|
end
|
70
56
|
rescue
|
71
57
|
Lita.logger.warn "Error formatting message: #{data.inspect}"
|
72
58
|
end
|
73
59
|
|
60
|
+
def build_issue_message(data)
|
61
|
+
interpolate_message "web.#{data[:object_kind]}.#{data[:object_attributes][:state]}", data[:object_attributes]
|
62
|
+
end
|
63
|
+
|
64
|
+
def build_branch_message(data)
|
65
|
+
branch = data[:ref].split('/').drop(2).join('/')
|
66
|
+
data[:link] = "<#{data[:repository][:homepage]}|#{data[:repository][:name]}>"
|
67
|
+
if data[:before] =~ /^0+$/
|
68
|
+
interpolate_message 'web.push.new_branch', data
|
69
|
+
else
|
70
|
+
interpolate_message 'web.push.add_to_branch', data
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def build_merge_message(data)
|
75
|
+
url = "#{Lita.config.handlers.gitlab.url}"
|
76
|
+
url += if data[:project] then
|
77
|
+
"#{Lita.config.handlers.gitlab.group}/#{data[:project]}/merge_requests/#{data[:object_attributes][:iid]}"
|
78
|
+
else
|
79
|
+
"groups/#{Lita.config.handlers.gitlab.group}"
|
80
|
+
end
|
81
|
+
data[:object_attributes][:project] = data[:project]
|
82
|
+
data[:object_attributes][:link] = "<#{url}|#{data[:object_attributes][:title]}>"
|
83
|
+
interpolate_message "web.#{data[:object_kind]}.#{data[:object_attributes][:state]}", data[:object_attributes]
|
84
|
+
end
|
85
|
+
|
74
86
|
# General methods
|
75
87
|
|
76
|
-
def
|
88
|
+
def interpolate_message(key, data)
|
77
89
|
t(key) % data
|
78
90
|
end
|
79
91
|
|
data/lita-gitlab.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-gitlab'
|
3
|
-
spec.version = '1.0.
|
3
|
+
spec.version = '1.0.4'
|
4
4
|
spec.authors = ['Emilio Figueroa']
|
5
5
|
spec.email = ['emiliofigueroatorres@gmail.com']
|
6
6
|
spec.description = %q{A Lita handler that will display GitLab messages in the channel}
|
data/locales/en.yml
CHANGED
@@ -3,7 +3,7 @@ en:
|
|
3
3
|
handlers:
|
4
4
|
gitlab:
|
5
5
|
system:
|
6
|
-
user_add_to_team: "%{user_name} has joined the %{project_name} project"
|
6
|
+
user_add_to_team: "%{user_name} has joined to the %{project_name} project"
|
7
7
|
project_create: "%{owner_name} has created the %{name} project!"
|
8
8
|
project_destroy: "%{owner_name} has destroyed the %{name} project!"
|
9
9
|
user_remove_from_team: "%{user_name} has left the %{project_name} project"
|
@@ -15,11 +15,11 @@ en:
|
|
15
15
|
reopened: "The issue '%{title}' has been reopened."
|
16
16
|
closed: "The issue '%{title}' is now closed"
|
17
17
|
merge_request:
|
18
|
-
opened: "New merge-request: %{link}"
|
19
|
-
reopened: "The merge-request '%{link}' has been reopened."
|
20
|
-
closed: "The merge-request '%{title}' is now closed."
|
18
|
+
opened: "New merge-request #%{iid} en %{project}: %{link}"
|
19
|
+
reopened: "The merge-request #%{iid} en %{project} '%{link}' has been reopened."
|
20
|
+
closed: "The merge-request #%{iid} en %{project} '%{title}' is now closed."
|
21
21
|
locked: ""
|
22
|
-
merged: "Yay! The merge-request '%{link}' is has been merged."
|
22
|
+
merged: "Yay! The merge-request #%{iid} en %{project} '%{link}' is has been merged."
|
23
23
|
push:
|
24
|
-
new_branch: "%{user_name} created the new branch '%{link}'"
|
25
|
-
add_to_branch: "%{user_name} added %{total_commits_count} commits to branch '%{link}'"
|
24
|
+
new_branch: "%{user_name} created the new branch '%{link}' in project %{project}"
|
25
|
+
add_to_branch: "%{user_name} added %{total_commits_count} commits to branch '%{link}' in project %{project}"
|
File without changes
|
File without changes
|
File without changes
|
@@ -23,9 +23,12 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
23
23
|
let(:project) { 'test_project' }
|
24
24
|
let(:matchers) {
|
25
25
|
{
|
26
|
-
new_team_member: '
|
27
|
-
project_created: 'created',
|
28
|
-
project_destroyed: 'destroyed',
|
26
|
+
new_team_member: 'John Smith has joined to the StoreCloud project',
|
27
|
+
project_created: 'John Smith has created the StoreCloud project!',
|
28
|
+
project_destroyed: 'John Smith has destroyed the Underscore project!',
|
29
|
+
issue_opened: 'New issue >> New API: create/update/delete file: Create new API for manipulations with repository',
|
30
|
+
add_to_branch: "John Smith added 4 commits to branch '<http://localhost/diaspora|Diaspora>' in project test_project",
|
31
|
+
merge_request_opened: 'New merge-request #1 en test_project: <http://example.gitlab/group_name/test_project/merge_requests/1|MS-Viewport>'
|
29
32
|
}
|
30
33
|
}
|
31
34
|
|
@@ -46,7 +49,7 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
46
49
|
it 'notifies to the applicable rooms' do
|
47
50
|
expect(robot).to receive(:send_message) do |target, message|
|
48
51
|
expect(target.room).to eq('#baz')
|
49
|
-
expect(message).to
|
52
|
+
expect(message).to eq matchers[:new_team_member]
|
50
53
|
end
|
51
54
|
subject.receive(request, response)
|
52
55
|
end
|
@@ -61,7 +64,7 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
61
64
|
it 'notifies to the applicable rooms' do
|
62
65
|
expect(robot).to receive(:send_message) do |target, message|
|
63
66
|
expect(target.room).to eq('#baz')
|
64
|
-
expect(message).to
|
67
|
+
expect(message).to eq matchers[:project_created]
|
65
68
|
end
|
66
69
|
subject.receive(request, response)
|
67
70
|
end
|
@@ -76,7 +79,7 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
76
79
|
it 'notifies to the applicable rooms' do
|
77
80
|
expect(robot).to receive(:send_message) do |target, message|
|
78
81
|
expect(target.room).to eq('#baz')
|
79
|
-
expect(message).to
|
82
|
+
expect(message).to eq matchers[:project_destroyed]
|
80
83
|
end
|
81
84
|
subject.receive(request, response)
|
82
85
|
end
|
@@ -86,7 +89,7 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
86
89
|
context 'when web project hook' do
|
87
90
|
|
88
91
|
context 'when issue event' do
|
89
|
-
let(:issue_payload) { fixture_file('web/
|
92
|
+
let(:issue_payload) { fixture_file('web/issue_opened') }
|
90
93
|
before do
|
91
94
|
allow(params).to receive(:[]).with('payload').and_return(issue_payload)
|
92
95
|
end
|
@@ -94,14 +97,14 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
94
97
|
it 'notifies to the applicable rooms' do
|
95
98
|
expect(robot).to receive(:send_message) do |target, message|
|
96
99
|
expect(target.room).to eq('#baz')
|
97
|
-
expect(message).to
|
100
|
+
expect(message).to eq matchers[:issue_opened]
|
98
101
|
end
|
99
102
|
subject.receive(request, response)
|
100
103
|
end
|
101
104
|
end
|
102
105
|
|
103
106
|
context 'when push event' do
|
104
|
-
let(:push_payload) { fixture_file('web/
|
107
|
+
let(:push_payload) { fixture_file('web/add_to_branch') }
|
105
108
|
before do
|
106
109
|
allow(params).to receive(:[]).with('payload').and_return(push_payload)
|
107
110
|
end
|
@@ -109,14 +112,14 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
109
112
|
it 'notifies to the applicable rooms' do
|
110
113
|
expect(robot).to receive(:send_message) do |target, message|
|
111
114
|
expect(target.room).to eq('#baz')
|
112
|
-
expect(message).to
|
115
|
+
expect(message).to eq matchers[:add_to_branch]
|
113
116
|
end
|
114
117
|
subject.receive(request, response)
|
115
118
|
end
|
116
119
|
end
|
117
120
|
|
118
121
|
context 'when merge request event' do
|
119
|
-
let(:merge_request_payload) { fixture_file('web/
|
122
|
+
let(:merge_request_payload) { fixture_file('web/merge_request_opened') }
|
120
123
|
before do
|
121
124
|
allow(params).to receive(:[]).with('payload').and_return(merge_request_payload)
|
122
125
|
end
|
@@ -124,7 +127,7 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
124
127
|
it 'notifies to the applicable rooms' do
|
125
128
|
expect(robot).to receive(:send_message) do |target, message|
|
126
129
|
expect(target.room).to eq('#baz')
|
127
|
-
expect(message).to
|
130
|
+
expect(message).to eq matchers[:merge_request_opened]
|
128
131
|
end
|
129
132
|
subject.receive(request, response)
|
130
133
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-gitlab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emilio Figueroa
|
@@ -131,9 +131,9 @@ files:
|
|
131
131
|
- spec/fixtures/system/team_member_removed.json
|
132
132
|
- spec/fixtures/system/user_created.json
|
133
133
|
- spec/fixtures/system/user_removed.json
|
134
|
-
- spec/fixtures/web/
|
135
|
-
- spec/fixtures/web/
|
136
|
-
- spec/fixtures/web/
|
134
|
+
- spec/fixtures/web/add_to_branch.json
|
135
|
+
- spec/fixtures/web/issue_opened.json
|
136
|
+
- spec/fixtures/web/merge_request_opened.json
|
137
137
|
- spec/lita/handlers/gitlab_spec.rb
|
138
138
|
- spec/spec_helper.rb
|
139
139
|
homepage: https://github.com/milo-ft/lita-gitlab
|
@@ -168,8 +168,8 @@ test_files:
|
|
168
168
|
- spec/fixtures/system/team_member_removed.json
|
169
169
|
- spec/fixtures/system/user_created.json
|
170
170
|
- spec/fixtures/system/user_removed.json
|
171
|
-
- spec/fixtures/web/
|
172
|
-
- spec/fixtures/web/
|
173
|
-
- spec/fixtures/web/
|
171
|
+
- spec/fixtures/web/add_to_branch.json
|
172
|
+
- spec/fixtures/web/issue_opened.json
|
173
|
+
- spec/fixtures/web/merge_request_opened.json
|
174
174
|
- spec/lita/handlers/gitlab_spec.rb
|
175
175
|
- spec/spec_helper.rb
|