tefoji 2.0.0 → 2.1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tefoji/jira_api.rb +37 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c181a5680af5eebeab13d8a78d1e5430df0f3e7535cd9083771af8fbff6d3d06
4
- data.tar.gz: 9e0e8b9dcbc36cdbc093a038bd67d4b38f56197bf25695329d78f15c273e5ace
3
+ metadata.gz: 2c2caf0e00b4916388f8bfb1db2b6ad61317558ed7495d2b39573670c3d7ebc1
4
+ data.tar.gz: 11f6804530ed3bdcdfa68ef5caeee1f34c070695646b228fa5842493a060732e
5
5
  SHA512:
6
- metadata.gz: 40b84da52997e8df28012872982e3e50c2f3b18da3a2f80650d08c0f45525a3fa6803e1c9fdca9a82e6461c67882357ddc77d85125b39000176930bb6ccf3464
7
- data.tar.gz: 6396ee3ff93fd5214500ebe2913d5eddce18968741532e8c7a95b4547a4ffef7251fd9cf0667a30236503b76d1468f44e650f2816ca8815e0f8d6dbaf7891593
6
+ metadata.gz: ed85494595e4f21db5a8cd26f8b556e29e496481611c6a1322621c495151b94d9ea253450ca2dc0db79493bf8bb74bf0e7c0674ed54ded1974614347e9f523be
7
+ data.tar.gz: 4c00b11dcb3ef0179838b5bbcac8fdeb1c808905fcf6f9f3236150999cb7a2f696171ff539ad1d6653252f3eabef01664dc36785855aa1d395684d3504646d80
@@ -329,24 +329,18 @@ module Tefoji
329
329
 
330
330
  # Backward compatiblity: translate 'team' to 'scrum_team'
331
331
  scrum_team = issue_data['scrum_team'] || issue_data['team']
332
+
332
333
  if scrum_team
333
- if epic?(issue_data)
334
- jira_fields['components'] = [{ FIELD_NAME => scrum_team }]
335
- else
336
- jira_fields['customfield_11500'] = { FIELD_VALUE => scrum_team }
337
- end
334
+ field_name, field_value = scrum_team_rules(issue_data, scrum_team)
335
+ jira_fields[field_name] = field_value
338
336
  end
339
337
 
340
- # We're only allowed multiple teams (as 'components') in epics. For ordinary
341
- # issues take only the first of the list
338
+ # Backward compatiblity: translate 'teams' to 'scrum_teams'
342
339
  scrum_teams = issue_data['scrum_teams'] || issue_data['teams']
340
+
343
341
  if scrum_teams
344
- processed_teams = scrum_teams.to_a.flatten.reject { |t| t =~ /^\s*$/ }
345
- if epic?(issue_data)
346
- jira_fields['components'] = processed_teams.map { |team| { FIELD_NAME => team } }
347
- else
348
- jira_fields['customfield_11500'] = { FIELD_VALUE => processed_teams.first }
349
- end
342
+ field_name, field_value = scrum_teams_rules(issue_data, scrum_team)
343
+ jira_fields[field_name] = field_value
350
344
  end
351
345
 
352
346
  # Default issue type to ISSUE_TASK if it isn't already set
@@ -368,6 +362,36 @@ module Tefoji
368
362
  end
369
363
  end
370
364
 
365
+ # There are now some funky rules for setting the 'scrum_team' (previously 'team')
366
+ # and 'scrum_teams' field in different issues.
367
+ #
368
+ # For epics, put the scrum team in the 'components' field.
369
+ # Except for a couple of projects, put the scrum team in customfield_11500
370
+ # For Puppet Agent (PA) and Puppet Server (SERVER) projects, put the scrum team in
371
+ # customfield_14200
372
+ def scrum_team_rules(issue_data, scrum_team)
373
+ if epic?(issue_data)
374
+ return ['components', [{ FIELD_NAME => scrum_team }]]
375
+ end
376
+
377
+ customfield = 'customfield_11500'
378
+ if %w[PA SERVER].include?(issue_data['project'].value)
379
+ customfield = 'customfield_14200'
380
+ end
381
+
382
+ return [customfield, { FIELD_VALUE => scrum_team }]
383
+ end
384
+
385
+ def scrum_teams_rules(issue_data, scrum_teams)
386
+ processed_teams = scrum_teams.to_a.flatten.reject { |t| t =~ /^\s*$/ }
387
+ if epic?(issue_data)
388
+ return ['components', processed_teams.map { |team| { FIELD_NAME => team } }]
389
+ end
390
+
391
+ # For ordinary issues we can only set one team.
392
+ scrum_team_rules(issue_data, processed_teams.first)
393
+ end
394
+
371
395
  def set_cloud_jira_fields(issue_data, jira_fields)
372
396
  if issue_data['assignee']
373
397
  assignee = issue_data['assignee']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tefoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-06-29 00:00:00.000000000 Z
11
+ date: 2023-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry-byebug