lita-gitlab 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/lita/handlers/gitlab.rb +17 -10
- data/lita-gitlab.gemspec +1 -1
- data/locales/en.yml +4 -2
- data/spec/lita/handlers/gitlab_spec.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0cb4c7e98cb5e2a1b5db2425979af203a10c8fe
|
4
|
+
data.tar.gz: 7bf90c8a2f3453d8f3c567bf92b4a75b1b30bbb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5d62f466bfee6b6916b39c39b666abe28e045383777e6042449b3b93a8ac21ebb6cfe42e89de6f64d35248c69ed1daf4c2955c876a12f0355fea15015a408a6
|
7
|
+
data.tar.gz: 99b85bd8c00d17709a1444566fa160f7c225286027b7ba5cfa12775ef80667a405286c8ddb604a3808da45f0eb5e21ef80dc626cf7ab6293fef49b071c2a9f36
|
data/README.md
CHANGED
@@ -21,11 +21,19 @@ gem "lita-gitlab"
|
|
21
21
|
* `default_room` (String) - A channel idenitifier.
|
22
22
|
ie: `#general`.
|
23
23
|
|
24
|
+
* `url` (String) - The Gitlab repository location.
|
25
|
+
ie: `http://gitlab.mycompany.com/`.
|
26
|
+
|
27
|
+
* `group_name` (String) - Your group identifier.
|
28
|
+
ie: `my_team`.
|
29
|
+
|
24
30
|
### Example
|
25
31
|
|
26
32
|
``` ruby
|
27
33
|
Lita.configure do |config|
|
28
34
|
config.handlers.gitlab.default_room = '#general'
|
35
|
+
config.url = 'http://example.gitlab/'
|
36
|
+
config.group = 'group_name'
|
29
37
|
end
|
30
38
|
```
|
31
39
|
|
data/lib/lita/handlers/gitlab.rb
CHANGED
@@ -4,6 +4,8 @@ module Lita
|
|
4
4
|
|
5
5
|
def self.default_config(config)
|
6
6
|
config.default_room = '#general'
|
7
|
+
config.url = 'http://example.gitlab/'
|
8
|
+
config.group = 'group_name'
|
7
9
|
end
|
8
10
|
|
9
11
|
http.post '/lita/gitlab', :receive
|
@@ -11,15 +13,18 @@ module Lita
|
|
11
13
|
def receive(request, response)
|
12
14
|
json_body = request.params['payload'] || extract_json_from_request(request)
|
13
15
|
data = symbolize parse_payload(json_body)
|
16
|
+
data[:project] = request.params['project']
|
14
17
|
message = format_message(data)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
if message
|
19
|
+
targets = request.params['targets'] || self.config.default_room
|
20
|
+
rooms = []
|
21
|
+
targets.split(',').each do |param_target|
|
22
|
+
rooms << param_target
|
23
|
+
end
|
24
|
+
rooms.each do |room|
|
25
|
+
target = Source.new(room: room)
|
26
|
+
robot.send_message(target, message)
|
27
|
+
end
|
23
28
|
end
|
24
29
|
end
|
25
30
|
|
@@ -44,7 +49,9 @@ module Lita
|
|
44
49
|
if data.key? :object_kind
|
45
50
|
if data[:object_attributes].key? :target_branch
|
46
51
|
# Merge request
|
47
|
-
|
52
|
+
url = "#{self.config.url}"
|
53
|
+
url += data[:project] ? "#{self.config.group}/#{data[:project]}/merge_requests/#{data[:object_attributes][:iid]}" : "groups/#{self.config.group}"
|
54
|
+
data[:object_attributes][:link] = "<#{url}|#{data[:title]}>"
|
48
55
|
build_message "web.#{data[:object_kind]}.#{data[:object_attributes][:state]}", data[:object_attributes]
|
49
56
|
else
|
50
57
|
# Issue
|
@@ -53,7 +60,7 @@ module Lita
|
|
53
60
|
else
|
54
61
|
# Push has no object kind
|
55
62
|
branch = data[:ref].split('/').drop(2).join('/')
|
56
|
-
data[:link] = data[:repository][:name]
|
63
|
+
data[:link] = "<#{data[:repository][:homepage]}|#{data[:repository][:name]}>"
|
57
64
|
if data[:before] =~ /^0+$/
|
58
65
|
build_message 'web.push.new_branch', data
|
59
66
|
else
|
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.2'
|
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
@@ -15,9 +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: %{
|
19
|
-
reopened: "The merge-request '%{
|
18
|
+
opened: "New merge-request: %{link}"
|
19
|
+
reopened: "The merge-request '%{link}' has been reopened."
|
20
20
|
closed: "The merge-request '%{title}' is now closed."
|
21
|
+
locked: ""
|
22
|
+
merged: "Yay! The merge-request '%{link}' is has been merged."
|
21
23
|
push:
|
22
24
|
new_branch: "%{user_name} created the new branch '%{link}'"
|
23
25
|
add_to_branch: "%{user_name} added %{total_commits_count} commits to branch '%{link}'"
|
@@ -20,6 +20,7 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
20
20
|
let(:response) { Rack::Response.new }
|
21
21
|
let(:params) { {} }
|
22
22
|
let(:targets) { '#baz' }
|
23
|
+
let(:project) { 'test_project' }
|
23
24
|
let(:matchers) {
|
24
25
|
{
|
25
26
|
new_team_member: 'join',
|
@@ -31,6 +32,7 @@ describe Lita::Handlers::Gitlab, lita_handler: true do
|
|
31
32
|
describe '#receive' do
|
32
33
|
before :each do
|
33
34
|
allow(params).to receive(:[]).with('targets').and_return(targets)
|
35
|
+
allow(params).to receive(:[]).with('project').and_return(project)
|
34
36
|
end
|
35
37
|
|
36
38
|
context 'with system hook' do
|