lita-jira 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -11
- data/lib/jirahelper/issue.rb +18 -0
- data/lib/jirahelper/regex.rb +3 -0
- data/lib/lita/handlers/jira.rb +19 -2
- data/lita-jira.gemspec +3 -3
- data/locales/en.yml +7 -2
- data/spec/lita/handlers/jira_spec.rb +49 -23
- data/spec/spec_helper.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aef4c53ef081757f69c5313e99612eb6c9b5503a
|
4
|
+
data.tar.gz: 3c5ec6ad54539e97affbf462e71e3376aa9cdefd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bea64e3f8e3114be601474962ce76f006415fd2c797f76033242f8eaca6f5cb70a86980fb3b1c9f8cb77ec4974b73d5494642879700b1615f6acf6cea0339b69
|
7
|
+
data.tar.gz: ff5eb8303c4dbc703d07759b64724cc30898ea3eb1cef9da71a9cb0cb24a0a2e31333edf97b5a748e18b4b503751aa1ffadeaf0c52b97a35bd3c220b1e941757
|
data/README.md
CHANGED
@@ -34,25 +34,20 @@ config.handlers.jira.context = '' # If your instance is in a /subdirectory, put
|
|
34
34
|
|
35
35
|
```
|
36
36
|
todo <project> "<subject>" ["<summary>"] - Creates an issue in <project> with <subject> and optionally <summary>
|
37
|
-
jira <issue> - Shows a short summary <issue>
|
38
|
-
jira details <issue> - Shows all details about <issue>
|
39
|
-
jira assign <user> to <issue> - Assigns <user> to <issue>, <user> can be a 'Full Name' or a '@mentionname'
|
40
|
-
jira comment on <issue> <comment text> - Adds <comment text> to <issue>
|
41
37
|
```
|
42
38
|
|
43
|
-
### Search
|
44
|
-
|
45
39
|
```
|
46
|
-
jira
|
47
|
-
jira
|
40
|
+
jira <issue> - Shows a short summary <issue>
|
41
|
+
jira details <issue> - Shows all details about <issue>
|
42
|
+
jira comment on <issue> <comment text> - Adds <comment text> to <issue>
|
48
43
|
```
|
49
44
|
|
50
45
|
### Misc
|
51
46
|
|
52
47
|
```
|
53
|
-
jira identify <email address>
|
54
|
-
jira forget
|
55
|
-
jira whoami
|
48
|
+
jira identify <email address> - Associate your chat user with your email address
|
49
|
+
jira forget - Remove your chat user / email association
|
50
|
+
jira whoami - Show your chat user / email association
|
56
51
|
```
|
57
52
|
|
58
53
|
## License
|
data/lib/jirahelper/issue.rb
CHANGED
@@ -9,6 +9,13 @@ module JiraHelper
|
|
9
9
|
nil
|
10
10
|
end
|
11
11
|
|
12
|
+
def fetch_project(key)
|
13
|
+
client.Project.find(key)
|
14
|
+
rescue
|
15
|
+
log.error('JIRA HTTPError')
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
12
19
|
def format_issue(issue)
|
13
20
|
t('issue.details',
|
14
21
|
key: issue.key,
|
@@ -17,5 +24,16 @@ module JiraHelper
|
|
17
24
|
priority: issue.priority.name,
|
18
25
|
status: issue.status.name)
|
19
26
|
end
|
27
|
+
|
28
|
+
def create_issue(project, subject, summary)
|
29
|
+
project = fetch_project(project)
|
30
|
+
return nil unless project
|
31
|
+
issue = client.Issue.build
|
32
|
+
issue.save(fields: { subject: subject,
|
33
|
+
summary: summary,
|
34
|
+
project: { id: project.id } })
|
35
|
+
issue.fetch
|
36
|
+
issue
|
37
|
+
end
|
20
38
|
end
|
21
39
|
end
|
data/lib/jirahelper/regex.rb
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
module JiraHelper
|
3
3
|
# Regular expressions
|
4
4
|
module Regex
|
5
|
+
COMMENT_PATTERN = /\"(?<comment>.+)\"/
|
6
|
+
SUBJECT_PATTERN = /\"(?<subject>.+)\"/
|
7
|
+
SUMMARY_PATTERN = /\"(?<summary>.+)\"/
|
5
8
|
PROJECT_PATTERN = /(?<project>[a-zA-Z0-9]{1,10})/
|
6
9
|
ISSUE_PATTERN = /(?<issue>#{PROJECT_PATTERN}-[0-9]{1,5}+)/
|
7
10
|
EMAIL_PATTERN = /(?<email>[\w+\-.]+@[a-z\d\-]+(\.[a-z]+)*\.[a-z]+)/i
|
data/lib/lita/handlers/jira.rb
CHANGED
@@ -34,7 +34,7 @@ module Lita
|
|
34
34
|
)
|
35
35
|
|
36
36
|
route(
|
37
|
-
/^jira\scomment\son\s#{ISSUE_PATTERN}\s
|
37
|
+
/^jira\scomment\son\s#{ISSUE_PATTERN}\s#{COMMENT_PATTERN}$/,
|
38
38
|
:comment,
|
39
39
|
command: true,
|
40
40
|
help: {
|
@@ -42,10 +42,19 @@ module Lita
|
|
42
42
|
}
|
43
43
|
)
|
44
44
|
|
45
|
+
route(
|
46
|
+
/^todo\s#{PROJECT_PATTERN}\s#{SUBJECT_PATTERN}(\s#{SUMMARY_PATTERN})?$/,
|
47
|
+
:todo,
|
48
|
+
command: true,
|
49
|
+
help: {
|
50
|
+
t('help.todo.syntax') => t('help.todo.desc')
|
51
|
+
}
|
52
|
+
)
|
53
|
+
|
45
54
|
def summary(response)
|
46
55
|
issue = fetch_issue(response.match_data['issue'])
|
47
56
|
return response.reply(t('error.request')) unless issue
|
48
|
-
response.reply(
|
57
|
+
response.reply(t('issue.summary', key: issue.key, summary: issue.summary))
|
49
58
|
end
|
50
59
|
|
51
60
|
def details(response)
|
@@ -61,6 +70,14 @@ module Lita
|
|
61
70
|
comment.save!(body: response.match_data['comment'])
|
62
71
|
response.reply(t('comment.added', issue: issue.key))
|
63
72
|
end
|
73
|
+
|
74
|
+
def todo(response)
|
75
|
+
issue = create_issue(response.match_data['project'],
|
76
|
+
response.match_data['subject'],
|
77
|
+
response.match_data['summary'])
|
78
|
+
return response.reply(t('error.request')) unless issue
|
79
|
+
response.reply(t('issue.created', key: issue.key))
|
80
|
+
end
|
64
81
|
end
|
65
82
|
|
66
83
|
Lita.register_handler(Jira)
|
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.
|
3
|
+
spec.version = '0.5.0'
|
4
4
|
spec.authors = ['Eric Sigler']
|
5
5
|
spec.email = ['me@esigler.com']
|
6
|
-
spec.description = 'A
|
7
|
-
spec.summary = 'A
|
6
|
+
spec.description = 'A JIRA plugin for Lita.'
|
7
|
+
spec.summary = 'A JIRA plugin for Lita.'
|
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
@@ -17,19 +17,24 @@ en:
|
|
17
17
|
syntax: jira whoami
|
18
18
|
desc: Show your chat user / email association
|
19
19
|
comment:
|
20
|
-
syntax:
|
21
|
-
desc:
|
20
|
+
syntax: jira comment on <issue> <comment text>
|
21
|
+
desc: Adds <comment text> to <issue>
|
22
22
|
details:
|
23
23
|
syntax: jira details <issue>
|
24
24
|
desc: Shows detailed information for <issue>
|
25
25
|
summary:
|
26
26
|
syntax: jira <issue>
|
27
27
|
desc: Shows summary for <issue>
|
28
|
+
todo:
|
29
|
+
syntax: todo <project> "<subject>" ["<summary>"]
|
30
|
+
desc: Creates an issue in <project> with <subject> and optionally <summary>
|
28
31
|
identify:
|
29
32
|
stored: "You have been identified as %{email} to JIRA"
|
30
33
|
deleted: You have been de-identified from JIRA
|
31
34
|
email: "You are identified with JIRA as %{email}"
|
32
35
|
issue:
|
36
|
+
created: "Issue %{key} created"
|
33
37
|
details: "%{key}: %{summary}, assigned to: %{assigned}, priority: %{priority}, status: %{status}"
|
38
|
+
summary: "%{key}: %{summary}"
|
34
39
|
comment:
|
35
40
|
added: "Comment added to %{issue}"
|
@@ -1,48 +1,60 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Lita::Handlers::Jira, lita_handler: true do
|
4
|
-
let(:
|
5
|
-
double(summary: 'Some summary text',
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
let(:saved_issue) do
|
5
|
+
result = double(summary: 'Some summary text',
|
6
|
+
assignee: double(displayName: 'A Person'),
|
7
|
+
priority: double(name: 'P0'),
|
8
|
+
status: double(name: 'In Progress'),
|
9
|
+
key: 'XYZ-987')
|
10
|
+
allow(result).to receive('save') { true }
|
11
|
+
allow(result).to receive('fetch') { true }
|
12
|
+
result
|
10
13
|
end
|
11
14
|
|
12
|
-
let(:
|
13
|
-
|
14
|
-
|
15
|
-
r
|
15
|
+
let(:saved_project) do
|
16
|
+
double(key: 'XYZ',
|
17
|
+
id: 1)
|
16
18
|
end
|
17
19
|
|
18
|
-
let(:
|
20
|
+
let(:valid_client) do
|
21
|
+
issue = double
|
22
|
+
allow(issue).to receive_message_chain('Issue.find') { saved_issue }
|
23
|
+
allow(issue).to receive_message_chain('Issue.find.comments.build.save!') { saved_issue }
|
24
|
+
allow(issue).to receive_message_chain('Issue.build') { saved_issue }
|
25
|
+
allow(issue).to receive_message_chain('Project.find') { saved_project }
|
26
|
+
issue
|
27
|
+
end
|
28
|
+
|
29
|
+
let(:failed_find_issue) do
|
19
30
|
r = double
|
20
31
|
expect(r).to receive_message_chain('Issue.find').and_throw(JIRA::HTTPError)
|
21
32
|
r
|
22
33
|
end
|
23
34
|
|
24
|
-
let(:
|
35
|
+
let(:failed_find_project) do
|
25
36
|
r = double
|
26
|
-
expect(r).to receive_message_chain('
|
27
|
-
expect(r).to receive_message_chain('Issue.find.comments.build.save!') { basic_issue }
|
37
|
+
expect(r).to receive_message_chain('Project.find').and_throw(JIRA::HTTPError)
|
28
38
|
r
|
29
39
|
end
|
30
40
|
|
31
41
|
it do
|
32
|
-
is_expected.to route_command('jira ABC-123')
|
33
|
-
is_expected.to route_command('jira details ABC-123')
|
34
|
-
is_expected.to route_command('jira comment on ABC-123 "You just need a cat"')
|
42
|
+
is_expected.to route_command('jira ABC-123').to(:summary)
|
43
|
+
is_expected.to route_command('jira details ABC-123').to(:details)
|
44
|
+
is_expected.to route_command('jira comment on ABC-123 "You just need a cat"').to(:comment)
|
45
|
+
is_expected.to route_command('todo ABC "summary text"').to(:todo)
|
46
|
+
is_expected.to route_command('todo ABC "summary text" "subject text"').to(:todo)
|
35
47
|
end
|
36
48
|
|
37
49
|
describe '#summary' do
|
38
50
|
it 'shows summary with a valid issue' do
|
39
|
-
grab_request(
|
51
|
+
grab_request(valid_client)
|
40
52
|
send_command('jira XYZ-987')
|
41
53
|
expect(replies.last).to eq('XYZ-987: Some summary text')
|
42
54
|
end
|
43
55
|
|
44
56
|
it 'warns the user when the issue is not valid' do
|
45
|
-
grab_request(
|
57
|
+
grab_request(failed_find_issue)
|
46
58
|
send_command('jira XYZ-987')
|
47
59
|
expect(replies.last).to eq('Error fetching JIRA issue')
|
48
60
|
end
|
@@ -50,14 +62,14 @@ describe Lita::Handlers::Jira, lita_handler: true do
|
|
50
62
|
|
51
63
|
describe '#details' do
|
52
64
|
it 'shows details with a valid issue' do
|
53
|
-
grab_request(
|
65
|
+
grab_request(valid_client)
|
54
66
|
send_command('jira details XYZ-987')
|
55
67
|
expect(replies.last).to eq('XYZ-987: Some summary text, assigned to: ' \
|
56
68
|
'A Person, priority: P0, status: In Progress')
|
57
69
|
end
|
58
70
|
|
59
71
|
it 'warns the user when the issue is not valid' do
|
60
|
-
grab_request(
|
72
|
+
grab_request(failed_find_issue)
|
61
73
|
send_command('jira details XYZ-987')
|
62
74
|
expect(replies.last).to eq('Error fetching JIRA issue')
|
63
75
|
end
|
@@ -65,15 +77,29 @@ describe Lita::Handlers::Jira, lita_handler: true do
|
|
65
77
|
|
66
78
|
describe '#comment' do
|
67
79
|
it 'updates the comment with a valid issue and comment text' do
|
68
|
-
grab_request(
|
80
|
+
grab_request(valid_client)
|
69
81
|
send_command('jira comment on XYZ-987 "Testing"')
|
70
82
|
expect(replies.last).to eq('Comment added to XYZ-987')
|
71
83
|
end
|
72
84
|
|
73
85
|
it 'warns the user when the issue is not valid' do
|
74
|
-
grab_request(
|
86
|
+
grab_request(failed_find_issue)
|
75
87
|
send_command('jira comment on XYZ-987 "Testing"')
|
76
88
|
expect(replies.last).to eq('Error fetching JIRA issue')
|
77
89
|
end
|
78
90
|
end
|
91
|
+
|
92
|
+
describe '#todo' do
|
93
|
+
it 'creates a new issue if the project is valid and there is a summary' do
|
94
|
+
grab_request(valid_client)
|
95
|
+
send_command('todo XYZ "Some summary text"')
|
96
|
+
expect(replies.last).to eq('Issue XYZ-987 created')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'warns the user when the project is not valid' do
|
100
|
+
grab_request(failed_find_project)
|
101
|
+
send_command('todo ABC "Some summary text"')
|
102
|
+
expect(replies.last).to eq('Error fetching JIRA issue')
|
103
|
+
end
|
104
|
+
end
|
79
105
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-jira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Sigler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description: A
|
125
|
+
description: A JIRA plugin for Lita.
|
126
126
|
email:
|
127
127
|
- me@esigler.com
|
128
128
|
executables: []
|
@@ -173,7 +173,7 @@ rubyforge_project:
|
|
173
173
|
rubygems_version: 2.2.2
|
174
174
|
signing_key:
|
175
175
|
specification_version: 4
|
176
|
-
summary: A
|
176
|
+
summary: A JIRA plugin for Lita.
|
177
177
|
test_files:
|
178
178
|
- spec/lita/handlers/jira_spec.rb
|
179
179
|
- spec/lita/handlers/jira_utility_spec.rb
|