lita-jira 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CONTRIBUTING.md +4 -0
- data/README.md +20 -2
- data/lib/jirahelper/issue.rb +19 -4
- data/lib/lita/handlers/jira.rb +23 -5
- data/lita-jira.gemspec +4 -4
- data/locales/en.yml +2 -1
- data/spec/lita/handlers/jira_spec.rb +93 -7
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 372aaea44e1c7953b66a0cb3afe6a53a631e08c9
|
4
|
+
data.tar.gz: 8ffc592e14e99e246d07effe13f1248d850c7a3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74d908bfa0e64d3d9331447e75873797b5d1fb8ae485da8beff3c1ecf49cc1faa830ec41e66a4f8a7a646684e531fb8124350f193510457b3b5814944e96a439
|
7
|
+
data.tar.gz: 76ef2321482c259b729f97475525e671d084fdf6992e68c01b694aff11de65c3b943eae4a5a31d867560709558c1f67edda4e1ab86014cb8f1b79aa6868a083a
|
data/.rubocop.yml
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -7,3 +7,7 @@ Pull requests are awesome! Pull requests with tests are even more awesome!
|
|
7
7
|
3. Add a test for your change. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, it needs a test!
|
8
8
|
4. Make the test pass.
|
9
9
|
5. Push to your fork and submit a pull request.
|
10
|
+
|
11
|
+
## Reminders
|
12
|
+
|
13
|
+
* Be sure to add yourself to the Gemspec
|
data/README.md
CHANGED
@@ -21,11 +21,25 @@ gem "lita-jira"
|
|
21
21
|
|
22
22
|
Add the following variables to your lita config file:
|
23
23
|
|
24
|
-
```
|
24
|
+
``` ruby
|
25
25
|
config.handlers.jira.username = 'your_jira_username'
|
26
26
|
config.handlers.jira.password = 'a_password'
|
27
27
|
config.handlers.jira.site = 'https://your.jira.instance.example.com/'
|
28
|
-
|
28
|
+
```
|
29
|
+
|
30
|
+
### Optional attributes
|
31
|
+
* `context` (string) - If your instance is in a /subdirectory, put that here. Default: `''`
|
32
|
+
* `format` (string) - You can select a compact one line issue summary by setting this parameter to `one-line`. Default: `verbose`
|
33
|
+
* `ambient` (boolean) - When set to `true`, Lita will show JIRA issue details when a JIRA issue key is mentioned in chat, outside the context of a command. Default: `false`
|
34
|
+
* `ignore` (array) - Prevent ambient JIRA issue detection in certain users' messages. Default: `[]`
|
35
|
+
* `rooms` (array) - Limit ambient JIRA issue detection to a certain list of rooms. If unspecified, the bot will respond to detected issues in all rooms.
|
36
|
+
|
37
|
+
``` ruby
|
38
|
+
config.handlers.jira.context = '/myjira'
|
39
|
+
config.handlers.jira.ambient = true
|
40
|
+
config.handlers.jira.format = 'one-line'
|
41
|
+
config.handlers.jira.ignore = ['Jira', 'Github']
|
42
|
+
config.handlers.jira.rooms = ['devtools', 'engineering']
|
29
43
|
```
|
30
44
|
|
31
45
|
## Usage
|
@@ -51,6 +65,10 @@ jira forget - Remove your chat user / email association
|
|
51
65
|
jira whoami - Show your chat user / email association
|
52
66
|
```
|
53
67
|
|
68
|
+
## CHANGELOG
|
69
|
+
|
70
|
+
[CHANGELOG](https://github.com/esigler/lita-jira/releases)
|
71
|
+
|
54
72
|
## License
|
55
73
|
|
56
74
|
[MIT](http://opensource.org/licenses/MIT)
|
data/lib/jirahelper/issue.rb
CHANGED
@@ -2,12 +2,15 @@
|
|
2
2
|
module JiraHelper
|
3
3
|
# Issues
|
4
4
|
module Issue
|
5
|
-
|
5
|
+
# NOTE: Prefer this syntax here as it's cleaner
|
6
|
+
# rubocop:disable Style/RescueEnsureAlignment
|
7
|
+
def fetch_issue(key, expected = true)
|
6
8
|
client.Issue.find(key)
|
7
9
|
rescue
|
8
|
-
log.error('JIRA HTTPError')
|
10
|
+
log.error('JIRA HTTPError') if expected
|
9
11
|
nil
|
10
12
|
end
|
13
|
+
# rubocop:enable Style/RescueEnsureAlignment
|
11
14
|
|
12
15
|
# Leverage the jira-ruby Issue.jql search feature
|
13
16
|
#
|
@@ -17,21 +20,29 @@ module JiraHelper
|
|
17
20
|
client.Issue.jql(jql)
|
18
21
|
end
|
19
22
|
|
23
|
+
# NOTE: Prefer this syntax here as it's cleaner
|
24
|
+
# rubocop:disable Style/RescueEnsureAlignment
|
20
25
|
def fetch_project(key)
|
21
26
|
client.Project.find(key)
|
22
27
|
rescue
|
23
28
|
log.error('JIRA HTTPError')
|
24
29
|
nil
|
25
30
|
end
|
31
|
+
# rubocop:enable Style/RescueEnsureAlignment
|
26
32
|
|
33
|
+
# NOTE: Not breaking this function out just yet.
|
34
|
+
# rubocop:disable Metrics/AbcSize
|
27
35
|
def format_issue(issue)
|
28
|
-
t('issue.details',
|
36
|
+
t(config.format == 'one-line' ? 'issue.oneline' : 'issue.details',
|
29
37
|
key: issue.key,
|
30
38
|
summary: issue.summary,
|
39
|
+
status: issue.status.name,
|
31
40
|
assigned: optional_issue_property('unassigned') { issue.assignee.displayName },
|
41
|
+
fixVersion: optional_issue_property('none') { issue.fixVersions.first['name'] },
|
32
42
|
priority: optional_issue_property('none') { issue.priority.name },
|
33
|
-
|
43
|
+
url: format_issue_link(issue.key))
|
34
44
|
end
|
45
|
+
# rubocop:enable Metrics/AbcSize
|
35
46
|
|
36
47
|
# Enumerate issues returned from JQL query and format for response
|
37
48
|
#
|
@@ -42,6 +53,10 @@ module JiraHelper
|
|
42
53
|
results.concat(issues.map { |issue| format_issue(issue) })
|
43
54
|
end
|
44
55
|
|
56
|
+
def format_issue_link(key)
|
57
|
+
"#{config.site}#{config.context}/browse/#{key}"
|
58
|
+
end
|
59
|
+
|
45
60
|
def create_issue(project, subject, summary)
|
46
61
|
project = fetch_project(project)
|
47
62
|
return nil unless project
|
data/lib/lita/handlers/jira.rb
CHANGED
@@ -6,10 +6,14 @@ module Lita
|
|
6
6
|
class Jira < Handler
|
7
7
|
namespace 'Jira'
|
8
8
|
|
9
|
-
config :username, required: true
|
10
|
-
config :password, required: true
|
11
|
-
config :site, required: true
|
12
|
-
config :context, required:
|
9
|
+
config :username, required: true, type: String
|
10
|
+
config :password, required: true, type: String
|
11
|
+
config :site, required: true, type: String
|
12
|
+
config :context, required: false, type: String, default: ''
|
13
|
+
config :format, required: false, type: String, default: 'verbose'
|
14
|
+
config :ambient, required: false, types: [TrueClass, FalseClass], default: false
|
15
|
+
config :ignore, required: false, type: Array, default: []
|
16
|
+
config :rooms, required: false, type: Array
|
13
17
|
|
14
18
|
include ::JiraHelper::Issue
|
15
19
|
include ::JiraHelper::Misc
|
@@ -61,6 +65,9 @@ module Lita
|
|
61
65
|
}
|
62
66
|
)
|
63
67
|
|
68
|
+
# Detect ambient JIRA issues in non-command messages
|
69
|
+
route ISSUE_PATTERN, :ambient, command: false
|
70
|
+
|
64
71
|
def summary(response)
|
65
72
|
issue = fetch_issue(response.match_data['issue'])
|
66
73
|
return response.reply(t('error.request')) unless issue
|
@@ -105,9 +112,20 @@ module Lita
|
|
105
112
|
|
106
113
|
response.reply(format_issues(issues))
|
107
114
|
end
|
115
|
+
|
116
|
+
def ambient(response)
|
117
|
+
return if invalid_ambient(response)
|
118
|
+
issue = fetch_issue(response.match_data['issue'], false)
|
119
|
+
response.reply(format_issue(issue)) if issue
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def invalid_ambient(response)
|
125
|
+
response.message.command? || !config.ambient || config.ignore.include?(response.user.name) || (config.rooms && !config.rooms.include?(response.message.source.room))
|
126
|
+
end
|
108
127
|
# rubocop:enable Metrics/AbcSize
|
109
128
|
end
|
110
|
-
|
111
129
|
Lita.register_handler(Jira)
|
112
130
|
end
|
113
131
|
end
|
data/lita-jira.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-jira'
|
3
|
-
spec.version = '0.
|
4
|
-
spec.authors = ['Eric Sigler']
|
5
|
-
spec.email = ['me@esigler.com']
|
3
|
+
spec.version = '0.7.0'
|
4
|
+
spec.authors = ['Eric Sigler', 'Matt Critchlow']
|
5
|
+
spec.email = ['me@esigler.com', 'matt.critchlow@gmail.com']
|
6
6
|
spec.description = 'A JIRA plugin for Lita.'
|
7
|
-
spec.summary =
|
7
|
+
spec.summary = spec.description
|
8
8
|
spec.homepage = 'https://github.com/esigler/lita-jira'
|
9
9
|
spec.license = 'MIT'
|
10
10
|
spec.metadata = { 'lita_plugin_type' => 'handler' }
|
data/locales/en.yml
CHANGED
@@ -37,7 +37,8 @@ en:
|
|
37
37
|
email: "You are identified with JIRA as %{email}"
|
38
38
|
issue:
|
39
39
|
created: "Issue %{key} created"
|
40
|
-
details: "%{key}
|
40
|
+
details: "[%{key}] %{summary}\nStatus: %{status}, assigned to: %{assigned}, fixVersion: %{fixVersion}, priority: %{priority}\n%{url}"
|
41
|
+
oneline: "%{url} - %{status}, %{assigned} - %{summary}"
|
41
42
|
summary: "%{key}: %{summary}"
|
42
43
|
comment:
|
43
44
|
added: "Comment added to %{issue}"
|
@@ -1,11 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Lita::Handlers::Jira, lita_handler: true do
|
4
|
+
before do
|
5
|
+
registry.config.handlers.jira.site = 'http://jira.local'
|
6
|
+
end
|
7
|
+
|
4
8
|
let(:saved_issue) do
|
5
9
|
result = double(summary: 'Some summary text',
|
6
10
|
assignee: double(displayName: 'A Person'),
|
7
11
|
priority: double(name: 'P0'),
|
8
12
|
status: double(name: 'In Progress'),
|
13
|
+
fixVersions: [{ 'name' => 'Sprint 2' }],
|
9
14
|
key: 'XYZ-987')
|
10
15
|
allow(result).to receive('save') { true }
|
11
16
|
allow(result).to receive('fetch') { true }
|
@@ -15,6 +20,7 @@ describe Lita::Handlers::Jira, lita_handler: true do
|
|
15
20
|
let(:saved_issue_with_fewer_details) do
|
16
21
|
result = double(summary: 'Some summary text',
|
17
22
|
status: double(name: 'In Progress'),
|
23
|
+
fixVersions: [],
|
18
24
|
key: 'XYZ-987')
|
19
25
|
allow(result).to receive('assignee').and_raise
|
20
26
|
allow(result).to receive('priority').and_raise
|
@@ -28,11 +34,13 @@ describe Lita::Handlers::Jira, lita_handler: true do
|
|
28
34
|
assignee: double(displayName: 'A Person'),
|
29
35
|
priority: double(name: 'P0'),
|
30
36
|
status: double(name: 'In Progress'),
|
37
|
+
fixVersions: [{ 'name' => 'Sprint 2' }],
|
31
38
|
key: 'XYZ-987'),
|
32
39
|
double(summary: 'Some summary text 2',
|
33
40
|
assignee: double(displayName: 'A Person 2'),
|
34
41
|
priority: double(name: 'P1'),
|
35
42
|
status: double(name: 'In Progress 2'),
|
43
|
+
fixVersions: [],
|
36
44
|
key: 'XYZ-988')]
|
37
45
|
allow(result).to receive('save') { true }
|
38
46
|
allow(result).to receive('fetch') { true }
|
@@ -111,15 +119,21 @@ describe Lita::Handlers::Jira, lita_handler: true do
|
|
111
119
|
it 'shows details with a valid issue' do
|
112
120
|
grab_request(valid_client)
|
113
121
|
send_command('jira details XYZ-987')
|
114
|
-
expect(replies.last).to eq(
|
115
|
-
'A Person, priority: P0, status: In Progress')
|
122
|
+
expect(replies.last).to eq("[XYZ-987] Some summary text\nStatus: In Progress, assigned to: A Person, fixVersion: Sprint 2, priority: P0\nhttp://jira.local/browse/XYZ-987")
|
116
123
|
end
|
117
124
|
|
118
125
|
it 'shows fewer details when the property is not set' do
|
119
126
|
grab_request(client_with_fewer_details)
|
120
127
|
send_command('jira details XYZ-987')
|
121
|
-
expect(replies.last).to eq(
|
122
|
-
|
128
|
+
expect(replies.last).to eq("[XYZ-987] Some summary text\nStatus: In Progress, assigned to: unassigned, fixVersion: none, priority: none\nhttp://jira.local/browse/XYZ-987")
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'displays the correct URL when config.context is set' do
|
132
|
+
registry.config.handlers.jira.context = '/myjira'
|
133
|
+
grab_request(valid_client)
|
134
|
+
send_command('jira details XYZ-987')
|
135
|
+
expect(replies.last).to eq("[XYZ-987] Some summary text\nStatus: In Progress, assigned to: A Person, fixVersion: Sprint 2, priority: P0\nhttp://jira.local/myjira/browse/XYZ-987")
|
136
|
+
registry.config.handlers.jira.context = ''
|
123
137
|
end
|
124
138
|
|
125
139
|
it 'warns the user when the issue is not valid' do
|
@@ -127,6 +141,14 @@ describe Lita::Handlers::Jira, lita_handler: true do
|
|
127
141
|
send_command('jira details XYZ-987')
|
128
142
|
expect(replies.last).to eq('Error fetching JIRA issue')
|
129
143
|
end
|
144
|
+
|
145
|
+
it 'shows details on one line with a valid issue if config.format is one-line' do
|
146
|
+
registry.config.handlers.jira.format = 'one-line'
|
147
|
+
grab_request(valid_client)
|
148
|
+
send_command('jira details XYZ-987')
|
149
|
+
expect(replies.last).to eq('http://jira.local/browse/XYZ-987 - In Progress, A Person - Some summary text')
|
150
|
+
registry.config.handlers.jira.format = 'verbose'
|
151
|
+
end
|
130
152
|
end
|
131
153
|
|
132
154
|
describe '#comment' do
|
@@ -157,6 +179,68 @@ describe Lita::Handlers::Jira, lita_handler: true do
|
|
157
179
|
end
|
158
180
|
end
|
159
181
|
|
182
|
+
describe '#ambient' do
|
183
|
+
it 'does not show details for a detected issue by default' do
|
184
|
+
end
|
185
|
+
|
186
|
+
context 'when enabled in config' do
|
187
|
+
before(:each) do
|
188
|
+
registry.config.handlers.jira.ambient = true
|
189
|
+
grab_request(valid_client)
|
190
|
+
end
|
191
|
+
|
192
|
+
it 'shows details for a detected issue in a message' do
|
193
|
+
send_message('foo XYZ-987 bar')
|
194
|
+
expect(replies.last).to eq("[XYZ-987] Some summary text\nStatus: In Progress, assigned to: A Person, fixVersion: Sprint 2, priority: P0\nhttp://jira.local/browse/XYZ-987")
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'does not show details for a detected issue in a command' do
|
198
|
+
send_command('foo XYZ-987 bar')
|
199
|
+
expect(replies.size).to eq(0)
|
200
|
+
end
|
201
|
+
|
202
|
+
context 'and an ignore list is defined' do
|
203
|
+
before(:each) do
|
204
|
+
@user1 = Lita::User.create(1, name: 'User1')
|
205
|
+
@user2 = Lita::User.create(2, name: 'User2')
|
206
|
+
registry.config.handlers.jira.ignore = ['User2']
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'shows details for a detected issue sent by a user absent from the list' do
|
210
|
+
send_message('foo XYZ-987 bar', as: @user1)
|
211
|
+
expect(replies.last).to eq("[XYZ-987] Some summary text\nStatus: In Progress, assigned to: A Person, fixVersion: Sprint 2, priority: P0\nhttp://jira.local/browse/XYZ-987")
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'does not show details for a detected issue sent by a user on the list' do
|
215
|
+
send_message('foo XYZ-987 bar', as: @user2)
|
216
|
+
expect(replies.size).to eq(0)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
context 'and a room list is defined' do
|
221
|
+
def send_room_message(body, room)
|
222
|
+
robot.receive(Lita::Message.new(robot, body, Lita::Source.new(user: user, room: room)))
|
223
|
+
end
|
224
|
+
|
225
|
+
before(:each) do
|
226
|
+
@room1 = 'Room1'
|
227
|
+
@room2 = 'Room2'
|
228
|
+
registry.config.handlers.jira.rooms = [@room1]
|
229
|
+
end
|
230
|
+
|
231
|
+
it 'shows details for a detected issue sent in a room on the list' do
|
232
|
+
send_room_message('foo XYZ-987 bar', @room1)
|
233
|
+
expect(replies.last).to eq("[XYZ-987] Some summary text\nStatus: In Progress, assigned to: A Person, fixVersion: Sprint 2, priority: P0\nhttp://jira.local/browse/XYZ-987")
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'does not show details for a detected issue sent in a room absent from the list' do
|
237
|
+
send_room_message('foo XYZ-987 bar', @room2)
|
238
|
+
expect(replies.size).to eq(0)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
160
244
|
describe '#myissues' do
|
161
245
|
before { send_command('jira forget') }
|
162
246
|
context 'when not identified' do
|
@@ -178,9 +262,11 @@ describe Lita::Handlers::Jira, lita_handler: true do
|
|
178
262
|
it 'shows results when returned' do
|
179
263
|
grab_request(valid_client)
|
180
264
|
send_command('jira myissues')
|
181
|
-
expect(replies.last).to eq([
|
182
|
-
|
183
|
-
|
265
|
+
expect(replies.last).to eq([
|
266
|
+
'Here are issues currently assigned to you:',
|
267
|
+
"[XYZ-987] Some summary text\nStatus: In Progress, assigned to: A Person, fixVersion: Sprint 2, priority: P0\nhttp://jira.local/browse/XYZ-987",
|
268
|
+
"[XYZ-988] Some summary text 2\nStatus: In Progress 2, assigned to: A Person 2, fixVersion: none, priority: P1\nhttp://jira.local/browse/XYZ-988"
|
269
|
+
])
|
184
270
|
end
|
185
271
|
|
186
272
|
it 'shows an error when the search fails' do
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-jira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Sigler
|
8
|
+
- Matt Critchlow
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-07
|
12
|
+
date: 2015-08-07 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: lita
|
@@ -125,6 +126,7 @@ dependencies:
|
|
125
126
|
description: A JIRA plugin for Lita.
|
126
127
|
email:
|
127
128
|
- me@esigler.com
|
129
|
+
- matt.critchlow@gmail.com
|
128
130
|
executables: []
|
129
131
|
extensions: []
|
130
132
|
extra_rdoc_files: []
|
@@ -170,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
172
|
version: '0'
|
171
173
|
requirements: []
|
172
174
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.4.5
|
174
176
|
signing_key:
|
175
177
|
specification_version: 4
|
176
178
|
summary: A JIRA plugin for Lita.
|