bender-bot 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/bender/bot.rb +17 -9
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f6f1ca66046526eee7288deb9ea283f59587a76
4
- data.tar.gz: b7e9e5364f81483b33dd28f00146f261d0a2baf3
3
+ metadata.gz: 793607ad14d0ce9b2c1f7ccbb03b3607eb26581a
4
+ data.tar.gz: 9ea1a900427199fecbc1d15fc6a13240b9838350
5
5
  SHA512:
6
- metadata.gz: 94ab57468d52086d5602f01e60ef857d0c79a572e332d3090e395f7c39da331e25abed459a6608c913e245c0cfe53d3e3fbf454c9183946342737181fe53a502
7
- data.tar.gz: e138fb69f727b8e64eeb42928e1edb7bec532c314443a8d6dfb43737419ef78b7e4c82c882abc0959b51f9dab50b4fd50a9a50ae8ca98a91888805ac9066490b
6
+ metadata.gz: 21098770d0c695262389ee7bd36395bc316c70cefda86a552e8e41b2d843ee22d4146cc759312642047bf449338a3b3ade20cd3631d02d93aee7681eb4a950f9
7
+ data.tar.gz: 96527fd4de4d89b68ab83601b7461861476bed30f0c6e0e0a0f975aa5f860089f32813021470dde60c0e6caaa7ec0328bc97f6f2e3220917422bbe1e8baa70a8
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
@@ -32,9 +32,9 @@ class BenderBot
32
32
 
33
33
  JARO = FuzzyStringMatch::JaroWinkler.create :native
34
34
 
35
- CLOSE_TRANSITIONS = %w[ 21 41 ]
35
+ CLOSED_TRANSITIONS = %w[ 61 71 ]
36
36
 
37
- CLOSE_STATE = /done/i
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), :green
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
- CLOSE_TRANSITIONS.each do |tid|
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 =~ CLOSE_STATE
359
- 'Closed ' + incident_link(incident)
366
+ if status =~ CLOSED_STATE
367
+ [ 'Closed ' + incident_link(incident), :green ]
360
368
  else
361
369
  [
362
- 'Failed to close automatically, you might try yourself',
363
- (options.jira_site + '/browse/' + incident['key'])
364
- ].join("<br />")
370
+ "Failed to close #{incident_link(incident)} automatically, you might try yourself",
371
+ :red
372
+ ]
365
373
  end
366
374
  end
367
375
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bender-bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer