dependabot-common 0.99.2 → 0.99.3

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: 28a508e879f8d29ad3f3cd98cf1ca94678db0df808c10e164cf15d36321bc0ec
4
- data.tar.gz: ea6ac533a727a089319620295b1cc743dac84790f1ad68618984b49f94fabb72
3
+ metadata.gz: 4806c3daa2f6d726a4a4718411d198958e05a3df78aadcb989a10dcdbe4ccf05
4
+ data.tar.gz: 87a85c82d5830f41b3d4c7861f148db6190c4cb9606fb687a5048a4c88308c9d
5
5
  SHA512:
6
- metadata.gz: 727be6c321f6695caaedd18de54f763f9054c7a19b802eacd9cb11b5964aafeb283b0cd7256cdb003f4c1fbb7e304560a7e7e2e061e73b8db7b97bb4590c8feb
7
- data.tar.gz: '082c6fb68ead8199406eb90395d25e1df391b93a5b841e0139656b3422ee1ee7b3a2ad2b6259820a8ba17f635f209e8fa18e5dc70d740d6cb708d6cb903fe7ca'
6
+ metadata.gz: 286596b6d37125696ef60b9fc69c3c16b46a353b7b4dcb1d128a4ce4f1891fe360be6de53bc3a50179656615a35be2cd3f93b68fa1548f33f7a6062875f7ef91
7
+ data.tar.gz: 41a3b1c98c6591f17b88596d55072a6b376e3566c4095051b9d91e5b2a3b266cd632de2d54e36cf837c9d0668df84edaa6ed8aa047b8327e16e49e7af0e9a95f
@@ -35,7 +35,7 @@ module Dependabot
35
35
  end
36
36
 
37
37
  def create
38
- return if branch_exists? && pull_request_exists?
38
+ return if branch_exists?(branch_name) && pull_request_exists?
39
39
 
40
40
  commit = create_commit
41
41
  branch = create_or_update_branch(commit)
@@ -61,13 +61,13 @@ module Dependabot
61
61
  )
62
62
  end
63
63
 
64
- def branch_exists?
64
+ def branch_exists?(name)
65
65
  @branch_ref ||=
66
- github_client_for_source.ref(source.repo, "heads/#{branch_name}")
66
+ github_client_for_source.ref(source.repo, "heads/#{name}")
67
67
  if @branch_ref.is_a?(Array)
68
- @branch_ref.any? { |r| r.ref == "refs/heads/#{branch_name}" }
68
+ @branch_ref.any? { |r| r.ref == "refs/heads/#{name}" }
69
69
  else
70
- @branch_ref.ref == "refs/heads/#{branch_name}"
70
+ @branch_ref.ref == "refs/heads/#{name}"
71
71
  end
72
72
  rescue Octokit::NotFound
73
73
  false
@@ -162,7 +162,11 @@ module Dependabot
162
162
  end
163
163
 
164
164
  def create_or_update_branch(commit)
165
- branch_exists? ? update_branch(commit) : create_branch(commit)
165
+ if branch_exists?(branch_name)
166
+ update_branch(commit)
167
+ else
168
+ create_branch(commit)
169
+ end
166
170
  rescue Octokit::UnprocessableEntity
167
171
  # A race condition may cause GitHub to fail here, in which case we retry
168
172
  retry_count ||= 0
@@ -253,7 +257,14 @@ module Dependabot
253
257
  )
254
258
  rescue Octokit::UnprocessableEntity => error
255
259
  # Ignore races that we lose
256
- raise unless error.message.include?("pull request already exists")
260
+ return if error.message.include?("pull request already exists")
261
+
262
+ # Ignore cases where the target branch has been deleted
263
+ return if error.message.include?("field: base") &&
264
+ source.branch &&
265
+ !branch_exists?(source.branch)
266
+
267
+ raise
257
268
  end
258
269
 
259
270
  def default_branch
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.99.2"
4
+ VERSION = "0.99.3"
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.99.2
4
+ version: 0.99.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot