tefoji 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tefoji.rb +26 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 427d2dac516388b9bfe1db4ce55a164621c0530d30a9a79ce322fe098372d3a4
|
4
|
+
data.tar.gz: 756adc133f20f25d43f422149df86e17c685a741c10801150092ffd633265bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42c08df5f8727ad1b052b780478d1f66022a35eb2148001f5576eb41874a6334028a91552f02729d526ff96b9c1774606c8cbdc8666e2f83289ae9663ff8ab01
|
7
|
+
data.tar.gz: 1eb096e1869ae3bcedfebb77aacd69b4241d9f0062625850cbd8b1f3ecc4b04325c8e12eaa114ad6083f084b65e59029e46e26cfe0628f31543f049a01730483
|
data/lib/tefoji.rb
CHANGED
@@ -18,6 +18,8 @@ module Tefoji
|
|
18
18
|
include Logging
|
19
19
|
include UserFunctions
|
20
20
|
|
21
|
+
attr_accessor :template_data, :jira_api
|
22
|
+
|
21
23
|
# @param [Hash] user_options options provided by the user through the CLI.
|
22
24
|
# @see CLI
|
23
25
|
def initialize(user_options = {}, log_location = $stderr)
|
@@ -41,6 +43,7 @@ module Tefoji
|
|
41
43
|
@feature_issue = nil
|
42
44
|
@default_target_epic = nil
|
43
45
|
@epic_security = nil
|
46
|
+
@deferral_data = {}
|
44
47
|
|
45
48
|
# Logging
|
46
49
|
@log_level = Logger::INFO
|
@@ -282,8 +285,6 @@ module Tefoji
|
|
282
285
|
@jira_api.save_authentication(@jira_auth_file, @jira_cloud)
|
283
286
|
end
|
284
287
|
|
285
|
-
private
|
286
|
-
|
287
288
|
# Generate a feature, a list of epics, and associated issues
|
288
289
|
def generate_feature_with_issues
|
289
290
|
@feature_issue = generate_feature
|
@@ -300,7 +301,13 @@ module Tefoji
|
|
300
301
|
feature = variable_substitute(feature_to_do)
|
301
302
|
feature['type'] = JiraApi::ISSUE_NEW_FEATURE
|
302
303
|
|
304
|
+
short_name = feature['short_name'] || feature['summary']
|
305
|
+
|
303
306
|
@feature_issue = @jira_api.create_issue(feature, @jira_cloud)
|
307
|
+
@deferral_data[short_name.to_s] = {
|
308
|
+
'jira' => @feature_issue,
|
309
|
+
'raw' => feature
|
310
|
+
}
|
304
311
|
@logger.info "Feature issue: #{@feature_issue['key']}"
|
305
312
|
@feature_issue
|
306
313
|
end
|
@@ -366,6 +373,10 @@ module Tefoji
|
|
366
373
|
epic_issue['short_name'] = short_name
|
367
374
|
@logger.info 'Epic: %16s [%s]' % [epic_issue['key'], short_name]
|
368
375
|
@jira_api.link_issues(@feature_issue['key'], epic_issue['key']) if @feature_issue
|
376
|
+
@deferral_data[short_name.to_s] = {
|
377
|
+
'jira' => epic_issue,
|
378
|
+
'raw' => epic
|
379
|
+
}
|
369
380
|
epic_issue
|
370
381
|
end
|
371
382
|
end
|
@@ -385,10 +396,6 @@ module Tefoji
|
|
385
396
|
# Iterate through all issues in the template, creating each one in Jira.
|
386
397
|
# Link the issues back to their epic, if required
|
387
398
|
def generate_ordinary_issues
|
388
|
-
# Need to keep a map of tefoji data and associated responses from Jira to perform
|
389
|
-
# deferred updates, like blocked_by or watchers
|
390
|
-
deferral_data = {}
|
391
|
-
|
392
399
|
issue_defaults = {}
|
393
400
|
if @template_data.key?('issue_defaults')
|
394
401
|
issue_defaults = variable_substitute(@template_data['issue_defaults'])
|
@@ -417,12 +424,12 @@ module Tefoji
|
|
417
424
|
|
418
425
|
# deferral_data is kept to match the jira raw request data to the jira response data.
|
419
426
|
# This is needed so that deferred actions (like 'blocked_by') can be correctly mapped.
|
420
|
-
deferral_data[raw_issue_data['short_name'].to_s] = {
|
427
|
+
@deferral_data[raw_issue_data['short_name'].to_s] = {
|
421
428
|
'jira' => jira_issue,
|
422
429
|
'raw' => raw_issue_data
|
423
430
|
}
|
424
431
|
end
|
425
|
-
process_deferred_updates
|
432
|
+
process_deferred_updates
|
426
433
|
end
|
427
434
|
|
428
435
|
# Transform the tefoji issue data and tefoji issue_defaults into a hash that is ready to
|
@@ -538,16 +545,16 @@ module Tefoji
|
|
538
545
|
#
|
539
546
|
# @param deferral_data [Hash] raw template and jira response data
|
540
547
|
# @see generate_ordinary_issues
|
541
|
-
def process_deferred_updates
|
548
|
+
def process_deferred_updates
|
542
549
|
## Find deferred tags in the jira_epic_issues and do the required work
|
543
550
|
deferred_tags.each do |deferred_tag|
|
544
551
|
case deferred_tag
|
545
552
|
when 'blocked_by'
|
546
|
-
process_blocked_by
|
553
|
+
process_blocked_by
|
547
554
|
when 'status'
|
548
|
-
process_status
|
555
|
+
process_status
|
549
556
|
when 'watchers'
|
550
|
-
process_watchers
|
557
|
+
process_watchers
|
551
558
|
else
|
552
559
|
raise "Unimplemented deferred_tag: #{deferred_tag}"
|
553
560
|
end
|
@@ -557,10 +564,10 @@ module Tefoji
|
|
557
564
|
## The process_* methods have repeated code. This could be cleaned up
|
558
565
|
## with some well-thought-through functional techniques. Since the list
|
559
566
|
## of methods is short, I'll pass on that for now.
|
560
|
-
def process_blocked_by
|
567
|
+
def process_blocked_by
|
561
568
|
deferred_tag = 'blocked_by'
|
562
569
|
|
563
|
-
deferral_data.each_value do |deferral_hash|
|
570
|
+
@deferral_data.each_value do |deferral_hash|
|
564
571
|
raw_issue_data = deferral_hash['raw']
|
565
572
|
jira_issue_data = deferral_hash['jira']
|
566
573
|
next unless raw_issue_data.key?(deferred_tag)
|
@@ -568,10 +575,9 @@ module Tefoji
|
|
568
575
|
target_issues = [raw_issue_data[deferred_tag].value].flatten
|
569
576
|
target_issues.each do |target_issue_name|
|
570
577
|
this_issue_key = jira_issue_data['key']
|
571
|
-
|
572
578
|
# If we skipped creating the target issue because of a 'conditional',
|
573
579
|
# don't try to link to it.
|
574
|
-
target_issue_key = deferral_data.dig(target_issue_name, 'jira', 'key')
|
580
|
+
target_issue_key = @deferral_data.dig(target_issue_name, 'jira', 'key')
|
575
581
|
next if target_issue_key.nil?
|
576
582
|
|
577
583
|
@jira_api.link_issues(target_issue_key, this_issue_key)
|
@@ -580,10 +586,10 @@ module Tefoji
|
|
580
586
|
end
|
581
587
|
end
|
582
588
|
|
583
|
-
def process_status
|
589
|
+
def process_status
|
584
590
|
deferred_tag = 'status'
|
585
591
|
|
586
|
-
deferral_data.each_value do |deferral_hash|
|
592
|
+
@deferral_data.each_value do |deferral_hash|
|
587
593
|
raw_issue_data = deferral_hash['raw']
|
588
594
|
jira_issue_data = deferral_hash['jira']
|
589
595
|
next unless raw_issue_data.key?(deferred_tag)
|
@@ -600,10 +606,10 @@ module Tefoji
|
|
600
606
|
end
|
601
607
|
end
|
602
608
|
|
603
|
-
def process_watchers
|
609
|
+
def process_watchers
|
604
610
|
deferred_tag = 'watchers'
|
605
611
|
|
606
|
-
deferral_data.each_value do |deferral_hash|
|
612
|
+
@deferral_data.each_value do |deferral_hash|
|
607
613
|
raw_issue_data = deferral_hash['raw']
|
608
614
|
jira_issue_data = deferral_hash['jira']
|
609
615
|
|
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: 1.
|
4
|
+
version: 1.2.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-
|
11
|
+
date: 2023-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|