dependabot-common 0.111.52 → 0.111.53

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: 925cd9a1d7a6ec3a96b16b6ab9a0e43f4dc6feb40a17576510d55736be10d92e
4
- data.tar.gz: 19f1e06d849adef6843a046e22d2e9facd9794e6857a40ffba9baa3554cc45bc
3
+ metadata.gz: 2fd99525114b6d76a071677e573b8bd90ecf54e8ae8f4fd7bb7479c2b217f5cb
4
+ data.tar.gz: 1dc48dc0faa587760e59b98f46b7c20c65970bf8931f551f758643485205de1d
5
5
  SHA512:
6
- metadata.gz: d3c917a3e7efed516b150d15e1bca5a66d521ad36fb467ea672f7e3a93d75ead2cfdb9029f5e2fe54d69f92ea1d62269fab5d46e3c773318182cabae4bf056f1
7
- data.tar.gz: ea16f6e8ef46938cf06079c3f7d36596cf507cc305856758e2dbeb8534b6ed5f554c5df8cdfac16bbad262381f7381e77c433feb997a2d53a9a6724f706a8498
6
+ metadata.gz: 9674fc031ca500653cbae288db5b84b794e787f9001b03524fd8ef9ecb11ca6e0bc2ef2014eb8c3a36fa1a4ba418670aa28ae8604cec8ddc10295f998bc35b26
7
+ data.tar.gz: 3466cb3357c8b7873c6d3af10fc0f33bed0536acad0236f578a32b2fa10ea182fbe6645b68821820588972099ad01c2c96cef761ec31e132113f14b014bdb453
@@ -118,33 +118,40 @@ module Dependabot
118
118
  def create_commit
119
119
  tree = create_tree
120
120
 
121
- options = author_details&.any? ? { author: author_details } : {}
122
-
123
- if options[:author]&.any? && signature_key
124
- options[:author][:date] = Time.now.utc.iso8601
125
- options[:signature] = commit_signature(tree, options[:author])
126
- end
127
-
128
121
  begin
129
122
  github_client_for_source.create_commit(
130
123
  source.repo,
131
124
  commit_message,
132
125
  tree.sha,
133
126
  base_commit,
134
- options
127
+ commit_options(tree)
135
128
  )
136
129
  rescue Octokit::UnprocessableEntity => e
137
130
  raise unless e.message == "Tree SHA does not exist"
138
131
 
139
132
  # Sometimes a race condition on GitHub's side means we get an error
140
133
  # here. No harm in retrying if we do.
141
- retry_count ||= 0
142
- retry_count += 1
143
- raise if retry_count > 10
144
-
134
+ raise_or_increment_retry_counter(counter: @commit_creation, limit: 3)
145
135
  sleep(rand(1..1.99))
146
136
  retry
147
137
  end
138
+ rescue Octokit::UnprocessableEntity => e
139
+ raise unless e.message == "Tree SHA does not exist"
140
+
141
+ raise_or_increment_retry_counter(counter: @tree_creation, limit: 1)
142
+ sleep(rand(1..1.99))
143
+ retry
144
+ end
145
+
146
+ def commit_options(tree)
147
+ options = author_details&.any? ? { author: author_details } : {}
148
+
149
+ if options[:author]&.any? && signature_key
150
+ options[:author][:date] = Time.now.utc.iso8601
151
+ options[:signature] = commit_signature(tree, options[:author])
152
+ end
153
+
154
+ options
148
155
  end
149
156
 
150
157
  def create_tree
@@ -336,6 +343,12 @@ module Dependabot
336
343
  ).signature
337
344
  end
338
345
 
346
+ def raise_or_increment_retry_counter(counter:, limit:)
347
+ counter ||= 0
348
+ counter += 1
349
+ raise if counter > limit
350
+ end
351
+
339
352
  # rubocop:disable Metrics/CyclomaticComplexity
340
353
  def handle_error(err)
341
354
  case err
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.111.52"
4
+ VERSION = "0.111.53"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.111.52
4
+ version: 0.111.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot