tractive 1.0.19 → 1.0.22

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: 14ab65ca5e13687a2134222c4b6cf0317c0e41d4c7b995bce2d132c58ba835a7
4
+ data.tar.gz: e51c4df4366cfb597d65b0b193c7faf544a6d6608fccf36abc5bfd6b37fec857
5
5
  SHA512:
6
- metadata.gz: 51169ab9fe1e28040eb2d6cfe5e311b7c8c34a2c5d8d8c754724ee352974d523ef1f9602e2378f3269cc55fea599c4ee3ccae1770fb02b810e9ae7735c923a23
7
- data.tar.gz: abb9a23e369b87413212238c60e28fb5ea7fb680e844e1abd53d38af3e87bc28cc744bfc2a7fa2efebbfc1eadf72734d4e88383790adc433f389a99f0667ad89
6
+ metadata.gz: 90046baa72cf0faa7b58e7b439924fc04b1a9447da7565ab84eb678ef6dbe841bee98412d06b332f6d21136e75ba8e4bf5299c7385ad4f87064363ec3fed2b51
7
+ data.tar.gz: ad5480e82c6d0f1b1b3119e33a624fc6b31991d1783796dc05240fc796ff3039e9e4488c614f1d84c6e25518636dbecdc10282ab6cc4c474f8d77e1762ea832a
@@ -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,27 @@ 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
+ index = 0
79
+ curr_index = 0
80
+ changes.each do |change|
81
+ kind = change[:field] || "attachment"
82
+
83
+ next if %w[cc reporter version].include?(kind)
84
+
85
+ if kind == "comment" && (change[:newvalue].nil? || change[:newvalue].lstrip.empty?)
86
+ curr_index += 1
87
+ next
88
+ end
89
+
90
+ if kind == "comment"
91
+ @comments_map[curr_index] = index
92
+ curr_index += 1
93
+ end
94
+
95
+ index += 1
96
+ end
97
+
73
98
  if @singlepost
74
99
  body += comments.map { |x| x["body"] }.join("\n")
75
100
  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.22"
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.19
4
+ version: 1.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-01 00:00:00.000000000 Z
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql