tractive 1.0.17 → 1.0.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ead46f0c5389125439e3e887de0c60205625d751c86737ba4477e9967c4ae46e
4
- data.tar.gz: d93dd5f42054afe56f91cb9fbbb7d1dac9a0fcf42bca4307ab18097135809758
3
+ metadata.gz: 9f486ab9e712d09b64065d75d9a7f54eb6b7805e0a5aa14c90ec3094e36dd7d8
4
+ data.tar.gz: f7ec7b661d9f8a9210a3364f897443ab1d8e2969c74c36f7cf6271fe0003c465
5
5
  SHA512:
6
- metadata.gz: e385bd618aa607da18e7fddb41c4ecedc5a91cf981332bc825a951c1267555f8c351ee83ba3481411e32fc809a0771b52248a3f4971ed6e281d23e477362153b
7
- data.tar.gz: d3fcce3c20a4f5c004ed51d0548eb9f1b60f3bc70b78f8614fc02aa7fde2a47d522ec0e6afa410f7b6b4f02d6e4c73545167c44e53dc355bf4d27225cc8c2fc7
6
+ metadata.gz: 9355453a9074c3dd3b3a8aa7aed6326961b4193ec92c6d6dfe107ae1e6ee840a6709f95017f788ceee32e5edbb3fdb509301a378abe4dbdd64334879d9d1d151
7
+ data.tar.gz: 3faa452b99139fe2a688ab6cdd0a40a6403ccf7c457abee4e1c97aa424fc37ee06f0beed48d4e58bb15b8e3ba6fd410a3ddd3e90eab8424f025faf65e43d4df7
data/README.adoc CHANGED
@@ -506,6 +506,8 @@ milestones:
506
506
  ==== Attachments migration configuration
507
507
  `ticket | wiki:`:: specifies the options for the tickets or wikis
508
508
 
509
+ `delete_mocked:`::: Whether to delete mocked tickets after migration or not
510
+
509
511
  `attachments:`::: specifies method of obtaining attachments from Trac.
510
512
 
511
513
  `url:`:::: URL to obtain Trac attachments from
@@ -517,9 +519,12 @@ milestones:
517
519
  `export_script:`:::: output of a script that utilizes `trac-admin` to download
518
520
  all attachments from Trac.
519
521
 
522
+ NOTE: To delete the issues, an organization owner must enable deleting an issue for the organization's repositories, and you must have admin or owner permissions in the repository. For more information, see "https://docs.github.com/en/issues/tracking-your-work-with-issues/deleting-an-issue[deleting an issue]".
523
+
520
524
  [source,yaml]
521
525
  ----
522
526
  ticket:
527
+ delete_mocked: true
523
528
  attachments:
524
529
  url: https://abc.com/raw-attachment/ticket
525
530
  hashed: true
@@ -15,17 +15,17 @@ module Http
15
15
  retries += 1
16
16
  RestClient::Request.execute(@args, &block)
17
17
  rescue RestClient::Forbidden => e
18
- retry_after = e.http_headers[:x_ratelimit_reset].to_i - Time.now.to_i
18
+ retry_after = e.http_headers[:x_ratelimit_reset].to_i - Time.now.to_i + 5
19
19
  raise e if retry_after.negative? || retries > @max_retries
20
20
 
21
21
  while retry_after.positive?
22
22
  minutes = retry_after / 60
23
23
  seconds = retry_after % 60
24
24
 
25
- print "\rRate Limit Exceeded, Will retry in #{minutes} min #{seconds} sec"
25
+ $logger.info "Rate Limit Exceeded, Will retry in #{minutes} min #{seconds} sec"
26
26
  sleep(1)
27
27
 
28
- retry_after = e.http_headers[:x_ratelimit_reset].to_i - Time.now.to_i
28
+ retry_after = e.http_headers[:x_ratelimit_reset].to_i - Time.now.to_i + 5
29
29
  end
30
30
  retry if retries <= @max_retries
31
31
  end
@@ -3,7 +3,11 @@
3
3
  module Migrator
4
4
  module Converter
5
5
  class TracToGithub
6
+ attr_reader :comments_map
7
+
6
8
  def initialize(args)
9
+ @comments_map = {}
10
+
7
11
  @trac_ticket_base_url = args[:cfg]["trac"]["ticketbaseurl"]
8
12
  @attachurl = args[:opts][:attachurl] || args[:cfg].dig("ticket", "attachments", "url")
9
13
  @changeset_base_url = args[:cfg]["trac"]["changeset_base_url"] || ""
@@ -70,6 +74,15 @@ module Migrator
70
74
 
71
75
  # replay all changes in chronological order:
72
76
  comments = changes.map { |x| ticket_change(@singlepost, x) }.select { |x| x }.to_a
77
+
78
+ curr_index = 0
79
+ changes.each_with_index do |change, index|
80
+ if change[:field] == "comment"
81
+ @comments_map[curr_index] = index
82
+ curr_index += 1
83
+ end
84
+ end
85
+
73
86
  if @singlepost
74
87
  body += comments.map { |x| x["body"] }.join("\n")
75
88
  comments = []
@@ -53,7 +53,8 @@ module Migrator
53
53
 
54
54
  $logger.info(%{creating issue for trac #{ticket[:id]} "#{ticket[:summary]}" (#{ticket[:reporter]})})
55
55
  # API details: https://gist.github.com/jonmagic/5282384165e0f86ef105
56
- request = Migrator::Converter::TracToGithub.new(@config).compose(ticket)
56
+ converter = Migrator::Converter::TracToGithub.new(@config)
57
+ request = converter.compose(ticket)
57
58
 
58
59
  response = @client.create_issue(@repo, request)
59
60
 
@@ -76,7 +77,7 @@ module Migrator
76
77
 
77
78
  $logger.info("created issue ##{issue_id} for trac ticket #{ticket[:id]}")
78
79
 
79
- update_comment_ref(issue_id) if request.to_s.include?("Replying to [comment:")
80
+ update_comment_ref(issue_id, converter.comments_map) if request.to_s.include?("Replying to [comment:")
80
81
 
81
82
  # assert correct issue number
82
83
  if issue_id != ticket[:id]
@@ -112,20 +112,21 @@ module Migrator
112
112
  }
113
113
  end
114
114
 
115
- def update_comment_ref(issue_id)
115
+ def update_comment_ref(issue_id, comments_map)
116
116
  comments = @client.issue_comments(@repo, issue_id)
117
117
  comments.each do |comment|
118
118
  next unless comment["body"].include?("Replying to [comment:")
119
119
 
120
- updated_comment_body = create_update_comment_params(comment, comments, issue_id)
120
+ updated_comment_body = create_update_comment_params(comment, comments, issue_id, comments_map)
121
121
  @client.update_issue_comment(@repo, comment["id"], updated_comment_body)
122
122
  end
123
123
  end
124
124
 
125
- def create_update_comment_params(comment, comments, issue_id)
125
+ def create_update_comment_params(comment, comments, issue_id, comments_map)
126
126
  body = comment["body"]
127
127
  matcher = body.match(/Replying to \[comment:(?<comment_number>\d+).*\]/)
128
- matched_comment = comments[matcher[:comment_number].to_i - 1]
128
+ comment_number = comments_map[matcher[:comment_number].to_i - 1]
129
+ matched_comment = comments[comment_number]
129
130
  body.gsub!(/Replying to \[comment:(\d+).*\]/, "Replying to [#{@repo}##{issue_id} (comment:\\1)](#{matched_comment["html_url"]})")
130
131
 
131
132
  body
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Tractive
4
- VERSION = "1.0.17"
4
+ VERSION = "1.0.20"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tractive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.17
4
+ version: 1.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-24 00:00:00.000000000 Z
11
+ date: 2022-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql