tractive 1.0.19 → 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: a64173c9e70060c2641b5022f266c5ef5af43fb56ba4bdb2e9453079e14ec2c0
4
- data.tar.gz: 2df9974ae895cff4d0a9a1c2c4acae81a1e6cdbc0f062edeb37f4d4ac7f7e782
3
+ metadata.gz: 9f486ab9e712d09b64065d75d9a7f54eb6b7805e0a5aa14c90ec3094e36dd7d8
4
+ data.tar.gz: f7ec7b661d9f8a9210a3364f897443ab1d8e2969c74c36f7cf6271fe0003c465
5
5
  SHA512:
6
- metadata.gz: 51169ab9fe1e28040eb2d6cfe5e311b7c8c34a2c5d8d8c754724ee352974d523ef1f9602e2378f3269cc55fea599c4ee3ccae1770fb02b810e9ae7735c923a23
7
- data.tar.gz: abb9a23e369b87413212238c60e28fb5ea7fb680e844e1abd53d38af3e87bc28cc744bfc2a7fa2efebbfc1eadf72734d4e88383790adc433f389a99f0667ad89
6
+ metadata.gz: 9355453a9074c3dd3b3a8aa7aed6326961b4193ec92c6d6dfe107ae1e6ee840a6709f95017f788ceee32e5edbb3fdb509301a378abe4dbdd64334879d9d1d151
7
+ data.tar.gz: 3faa452b99139fe2a688ab6cdd0a40a6403ccf7c457abee4e1c97aa424fc37ee06f0beed48d4e58bb15b8e3ba6fd410a3ddd3e90eab8424f025faf65e43d4df7
@@ -25,7 +25,7 @@ module Http
25
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.19"
4
+ VERSION = "1.0.20"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tractive
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.19
4
+ version: 1.0.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose