bender-bot 0.2.0 → 0.2.1
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/VERSION +1 -1
- data/lib/bender/bot.rb +17 -9
- 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: 793607ad14d0ce9b2c1f7ccbb03b3607eb26581a
|
4
|
+
data.tar.gz: 9ea1a900427199fecbc1d15fc6a13240b9838350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21098770d0c695262389ee7bd36395bc316c70cefda86a552e8e41b2d843ee22d4146cc759312642047bf449338a3b3ade20cd3631d02d93aee7681eb4a950f9
|
7
|
+
data.tar.gz: 96527fd4de4d89b68ab83601b7461861476bed30f0c6e0e0a0f975aa5f860089f32813021470dde60c0e6caaa7ec0328bc97f6f2e3220917422bbe1e8baa70a8
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/bender/bot.rb
CHANGED
@@ -32,9 +32,9 @@ class BenderBot
|
|
32
32
|
|
33
33
|
JARO = FuzzyStringMatch::JaroWinkler.create :native
|
34
34
|
|
35
|
-
|
35
|
+
CLOSED_TRANSITIONS = %w[ 61 71 ]
|
36
36
|
|
37
|
-
|
37
|
+
CLOSED_STATE = /close/i
|
38
38
|
|
39
39
|
SEVERITIES = {
|
40
40
|
1 => '10480',
|
@@ -220,7 +220,7 @@ class BenderBot
|
|
220
220
|
when /^\s*\/inc\s+close\s+(\d+)\s*$/
|
221
221
|
incident = select_incident $1
|
222
222
|
if incident
|
223
|
-
reply_html close_incident(incident)
|
223
|
+
reply_html *close_incident(incident)
|
224
224
|
else
|
225
225
|
reply_html 'Sorry, no such incident!', :red
|
226
226
|
end
|
@@ -334,6 +334,14 @@ private
|
|
334
334
|
|
335
335
|
|
336
336
|
def close_incident incident
|
337
|
+
status = normalize_value incident['fields']['status']
|
338
|
+
if status =~ CLOSED_STATE
|
339
|
+
return [
|
340
|
+
"#{incident_link(incident)} is already closed!",
|
341
|
+
:green
|
342
|
+
]
|
343
|
+
end
|
344
|
+
|
337
345
|
req_path = '/rest/api/2/issue/%s/transitions?expand=transitions.fields' % [
|
338
346
|
incident['key']
|
339
347
|
]
|
@@ -345,7 +353,7 @@ private
|
|
345
353
|
req['Content-Type'] = 'application/json'
|
346
354
|
req['Accept'] = 'application/json'
|
347
355
|
|
348
|
-
|
356
|
+
CLOSED_TRANSITIONS.each do |tid|
|
349
357
|
req.body = {
|
350
358
|
transition: { id: tid }
|
351
359
|
}.to_json
|
@@ -355,13 +363,13 @@ private
|
|
355
363
|
incident = select_incident incident['key'].split('-',2).last
|
356
364
|
status = normalize_value incident['fields']['status']
|
357
365
|
|
358
|
-
if status =~
|
359
|
-
'Closed ' + incident_link(incident)
|
366
|
+
if status =~ CLOSED_STATE
|
367
|
+
[ 'Closed ' + incident_link(incident), :green ]
|
360
368
|
else
|
361
369
|
[
|
362
|
-
|
363
|
-
|
364
|
-
]
|
370
|
+
"Failed to close #{incident_link(incident)} automatically, you might try yourself",
|
371
|
+
:red
|
372
|
+
]
|
365
373
|
end
|
366
374
|
end
|
367
375
|
|