tractive 1.0.18 → 1.0.21

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e08becfcae314c82bdc793b7eb6bc2f7b52f9a7be040b7141da825753a9f1af2
4
- data.tar.gz: 51385bdf7fcf7b12b110c852b9d0b9dc277240abf0b8c2f94b68b77db2839c32
3
+ metadata.gz: 7a10eeb2f828d2d135d48f0f6437f669c939104e17ef1b777e42d29e59aac5dc
4
+ data.tar.gz: df20934dfee4b890c9f633df93955f60d237987743c48f12a95a4bb8cb1b8806
5
5
  SHA512:
6
- metadata.gz: ad89e67997dd07cb3b6d65c5baca788033991122d8a10a73a64b09df79695ed8e2488b033dfaaa5fdd07d4a65c4ee5b4230121f3f7f094c8286bce352bcd6118
7
- data.tar.gz: 04f60f8190dbc644367c3095f28e4f7fddba04dfa5140a820dfbced58430fb3b1df1bb9c72dd10dadba6e4f66e1cfe9a2ea57f647bbf982452643824e87622f8
6
+ metadata.gz: 8dbc73bbf823c89b05267fb42991401f33c6e1097488b0e49bd4ec87a3c457ddfa500d6d16fd88793a6bb9ccd4a2c27514a74b1ca3e5c10786184284d691ae7f
7
+ data.tar.gz: ca6165b8852a0c5609737f5794683e8bb82c522934f861d59eb798a2475d8662b95742a76cd19c585a45980aa4a12cfaf3a35f169235c74ae2adb43851b667e4
@@ -15,7 +15,7 @@ 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?
@@ -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,22 @@ 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 unless interested_in_change?(kind, change[:newvalue])
84
+
85
+ if kind == "comment" || (kind == "attachment" && change[:description] != "")
86
+ @comments_map[curr_index] = index
87
+ curr_index += 1
88
+ end
89
+
90
+ index += 1
91
+ end
92
+
73
93
  if @singlepost
74
94
  body += comments.map { |x| x["body"] }.join("\n")
75
95
  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.18"
4
+ VERSION = "1.0.21"
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.18
4
+ version: 1.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-08 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