lita-jira-issues 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/README.md +47 -0
- data/lib/lita/handlers/jira_issues.rb +46 -20
- data/lita-jira-issues.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396330464997beb026d473b31a774c71595bc662
|
4
|
+
data.tar.gz: 7b0bee27654d8115df7d3a618957f62d5f796376
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3a51c8f7c7c43700a07b0d9dbedc2fadd3ead1b2eac519144760e3ffe8f251a71e7aa750f3d5baca350da99d74093012ccaf89808c5f3243527deba8554fdc2
|
7
|
+
data.tar.gz: 75e9b4693393632ba3589ec6b05fb933163056974ea100416fa156be319512427c22bea8d11955db4f298150bbf8214779f6fdac686944f595785a003682c54d
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
5
5
|
## [Unreleased][unreleased]
|
6
6
|
|
7
|
+
## [0.3.0] - 2015-06-21
|
8
|
+
### Added
|
9
|
+
- Fully customized response of the JIRA issue via templates. See the extensive
|
10
|
+
[documentation](https://github.com/amaltson/lita-jira-issues#customize-output)
|
11
|
+
on how to customize the formatting. Huge thanks to @hickey for the
|
12
|
+
contribution.
|
13
|
+
|
7
14
|
## [0.2.3] - 2015-04-29
|
8
15
|
### Added
|
9
16
|
- Optional TTL feature for silencing the same JIRA for a period of time. Thanks
|
@@ -29,7 +36,8 @@ to @johntdyer for the contribution.
|
|
29
36
|
https://github.com/github/hubot-scripts/blob/master/src/scripts/jira-issues.coffee)
|
30
37
|
|
31
38
|
|
32
|
-
[unreleased]: https://github.com/amaltson/lita-jira-issues/compare/v0.
|
39
|
+
[unreleased]: https://github.com/amaltson/lita-jira-issues/compare/v0.3.0...HEAD
|
40
|
+
[0.3.0]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.3...v0.3.0
|
33
41
|
[0.2.3]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.2...v0.2.3
|
34
42
|
[0.2.2]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.1...v0.2.2
|
35
43
|
[0.2.1]: https://github.com/amaltson/lita-jira-issues/compare/v0.2.0...v0.2.1
|
data/README.md
CHANGED
@@ -23,6 +23,8 @@ gem "lita-jira-issues"
|
|
23
23
|
|
24
24
|
## Configuration
|
25
25
|
|
26
|
+
### Base Configuration
|
27
|
+
|
26
28
|
The `jira_issues` handler needs to be configured with your JIRA instance. Add
|
27
29
|
the following configurations to your `lita_config.rb`.
|
28
30
|
|
@@ -31,11 +33,14 @@ config.handlers.jira_issues.url = 'http://jira.local'
|
|
31
33
|
config.handlers.jira_issues.username = ENV['JIRA_USER'] || 'user'
|
32
34
|
config.handlers.jira_issues.password = ENV['JIRA_PASSWORD'] || 'password'
|
33
35
|
config.handlers.jira_issues.issue_ttl = 0 #optional
|
36
|
+
config.handlers.jira_issues.format = '[%I] %S::%t' #optional
|
34
37
|
```
|
35
38
|
|
36
39
|
As in the example above, you can always use environment variables for sensitive
|
37
40
|
information like the JIRA user's password.
|
38
41
|
|
42
|
+
### Ignoring Users
|
43
|
+
|
39
44
|
Optionally you can prevent JIRA issue lookups from certain users using the ignore
|
40
45
|
configuration parameter
|
41
46
|
|
@@ -43,6 +48,8 @@ configuration parameter
|
|
43
48
|
config.handlers.jira_issues.ignore = [ 'Jira', 'Github' ]
|
44
49
|
```
|
45
50
|
|
51
|
+
### Avoid A Spamming Bot
|
52
|
+
|
46
53
|
Optionally you can set a timer for how long to sleep prior to posting an issue to chat again. This is accomplished by setting an expiring key in Redis. That timeout is governed by the following config
|
47
54
|
|
48
55
|
```ruby
|
@@ -51,6 +58,46 @@ config.handlers.jira_issues.issue_ttl = 120
|
|
51
58
|
|
52
59
|
The default for this config is 0 which serves to disables the feature entirely.
|
53
60
|
|
61
|
+
### Customize Output
|
62
|
+
|
63
|
+
You can now change the displayed format using keyword expansion. The following table of keywords can be used to create the response when a JIRA issue is referenced. Each keyword needs to be enclosed in %{} just as the Ruby `%` operator requires.
|
64
|
+
|
65
|
+
Each keyword can take one of 3 forms. If the keyword is specified in all CAPS, then the resulting text will be in all caps (i.e. 'KEY' => 'ABC-123'). If the keyword has an initial capital letter, then resulting text will be proper case (i.e. 'Key' => 'Abc-123'). Finally if the keyword is all lower case, then the resulting text will be the native format that the text was received in.
|
66
|
+
|
67
|
+
There is also a conditional syntax that can be use should the keyword not return a value. The conditional syntax roughly approximates a ternary operator found in several programming languages such as C, Java and Perl with slight modification to make pattern matching easier.
|
68
|
+
|
69
|
+
```
|
70
|
+
#(%{assignee}?Assigned to %{assignee}|UNASSIGNED)
|
71
|
+
```
|
72
|
+
|
73
|
+
In the above example, the start of the conditional syntax starts with the `#(` and is completed with the closing `)`. The first part (what is preceding the question mark) is what is evaluated. If the evaluation is not an empty string (i.e. ''), then the conditional syntax is replaced with the text between the question and the pipe (`|`) symbol. If the evaluation does return an empty string (i.e. assignee is not set), then the text following the pipe symbol will replace the conditional syntax. As one would expect, keyword substitutions occur within the conditional syntax.
|
74
|
+
|
75
|
+
By default the format is set to the original text displayed by the lita-jira-issues module.
|
76
|
+
|
77
|
+
```
|
78
|
+
[%{KEY}] %{summary}
|
79
|
+
Status: %{status}, #(%{assignee}?assigned to %{assignee}|unassigned), rep. by %{reporter}, fixVersion: #(%{version}?%{version}|NONE)#(%{priority}?, priority: %{priority}|)
|
80
|
+
%{link}
|
81
|
+
```
|
82
|
+
|
83
|
+
The response to referenced JIRA tickets are left up to you, but shortened formats are now available like:
|
84
|
+
|
85
|
+
```
|
86
|
+
[%{KEY}] %{PRIORITY}/%{Summary} - %{STATUS}\n%{link}
|
87
|
+
```
|
88
|
+
|
89
|
+
Pattern | Substitution
|
90
|
+
---------|-------------
|
91
|
+
key | Issue number
|
92
|
+
status | Issue status
|
93
|
+
summary | Issue summary
|
94
|
+
assignee | Assignee
|
95
|
+
reporter | Reporter
|
96
|
+
version | Version
|
97
|
+
priority | Priority
|
98
|
+
link | URL to JIRA issue page
|
99
|
+
url | Same as %{link}
|
100
|
+
|
54
101
|
## Usage
|
55
102
|
|
56
103
|
Simply mention any JIRA valid key in upper or lower case, eg. JIRA-123, proj-8,
|
@@ -5,11 +5,19 @@ module Lita
|
|
5
5
|
module Handlers
|
6
6
|
class JiraIssues < Handler
|
7
7
|
|
8
|
+
FORMAT = <<-FORMATTER
|
9
|
+
[%{KEY}] %{summary}
|
10
|
+
Status: %{status}, #(%{assignee}?assigned to %{assignee}|unassigned), rep. by %{reporter}, fixVersion: #(%{version}?%{version}|NONE)#(%{priority}?, priority: %{priority}|)
|
11
|
+
%{link}
|
12
|
+
FORMATTER
|
13
|
+
|
8
14
|
config :url, required: true, type: String
|
9
15
|
config :username, required: true, type: String
|
10
16
|
config :password, required: true, type: String
|
11
17
|
config :ignore, default: [], type: Array
|
12
18
|
config :issue_ttl, default: 0, type: Integer
|
19
|
+
config :format, default: FORMAT.chomp, type: String
|
20
|
+
|
13
21
|
|
14
22
|
route /[a-zA-Z]+-\d+/, :jira_message, help: {
|
15
23
|
"KEY-123" => "Replies with information about the given JIRA key"
|
@@ -34,53 +42,71 @@ module Lita
|
|
34
42
|
def issue_details(data)
|
35
43
|
key = data[:key]
|
36
44
|
data = data[:fields]
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
|
46
|
+
# build out the response from the configured format
|
47
|
+
text = config.format % {
|
48
|
+
KEY: key.upcase, Key: key.capitalize, key: key,
|
49
|
+
SUMMARY: summary(data).upcase, Summary: summary(data).capitalize, summary: summary(data),
|
50
|
+
ASSIGNEE: assignee(data).upcase, Assignee: assignee(data).capitalize, assignee: assignee(data),
|
51
|
+
REPORTER: reporter(data).upcase, Reporter: reporter(data).capitalize, reporter: reporter(data),
|
52
|
+
STATUS: status(data).upcase, Status: status(data).capitalize, status: status(data),
|
53
|
+
PRIORITY: priority(data).upcase, Priority: priority(data).capitalize, priority: priority(data),
|
54
|
+
VERSION: fix_version(data).upcase, Version: fix_version(data).capitalize, version: fix_version(data),
|
55
|
+
LINK: issue_link(key), link: issue_link(key),
|
56
|
+
URL: issue_link(key), url: issue_link(key)
|
57
|
+
}
|
58
|
+
|
59
|
+
# evaluate conditional syntax
|
60
|
+
text.gsub!(/#\(.*?\?.*?\|.*?\)/) do |cond_stmt|
|
61
|
+
vals = cond_stmt.match(/#\((?<value>.*?)\?(?<true_text>.*?)\|(?<false_text>.*?)\)/)
|
62
|
+
if vals[:value].empty?
|
63
|
+
vals[:false_text].gsub("\|", "|").gsub("\?", "?")
|
64
|
+
else
|
65
|
+
vals[:true_text].gsub("\|", "|").gsub("\?", "?")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
return text
|
48
70
|
end
|
49
71
|
|
50
72
|
def status(data)
|
51
|
-
|
73
|
+
data[:status][:name]
|
52
74
|
end
|
53
75
|
|
76
|
+
def summary(data)
|
77
|
+
data[:summary]
|
78
|
+
end
|
79
|
+
|
54
80
|
def assignee(data)
|
55
81
|
if assigned_to = data[:assignee]
|
56
|
-
return
|
82
|
+
return assigned_to[:displayName]
|
57
83
|
end
|
58
|
-
'
|
84
|
+
''
|
59
85
|
end
|
60
86
|
|
61
87
|
def reporter(data)
|
62
|
-
|
88
|
+
data[:reporter][:displayName]
|
63
89
|
end
|
64
90
|
|
65
91
|
def fix_version(data)
|
66
92
|
fix_versions = data[:fixVersions]
|
67
93
|
if fix_versions and fix_versions.first
|
68
|
-
|
94
|
+
fix_versions.first[:name]
|
69
95
|
else
|
70
|
-
'
|
96
|
+
''
|
71
97
|
end
|
72
98
|
end
|
73
99
|
|
74
100
|
def priority(data)
|
75
101
|
if data[:priority]
|
76
|
-
|
102
|
+
data[:priority][:name]
|
77
103
|
else
|
78
|
-
|
104
|
+
''
|
79
105
|
end
|
80
106
|
end
|
81
107
|
|
82
108
|
def issue_link(key)
|
83
|
-
"
|
109
|
+
"#{config.url}/browse/#{key}"
|
84
110
|
end
|
85
111
|
|
86
112
|
def silenced?(key)
|
data/lita-jira-issues.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-jira-issues
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Maltson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
152
|
version: '0'
|
153
153
|
requirements: []
|
154
154
|
rubyforge_project:
|
155
|
-
rubygems_version: 2.
|
155
|
+
rubygems_version: 2.4.4
|
156
156
|
signing_key:
|
157
157
|
specification_version: 4
|
158
158
|
summary: Lita handler that looks for JIRA issue keys and helpfully inserts details
|