dependabot-github_actions 0.388.0 → 0.389.0

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: 8ea7c22fb2ab0e5997b573cae9a2b3c99aa5faea4c0a827914256cf104ec9132
4
- data.tar.gz: ada08e07092d5019df0c05fa29a018fd0c05dd54c131c3a4df806347ac696fa8
3
+ metadata.gz: 28c1be16649f2941b1c6c5cb4f562eb1ef504dea136022b5a35519633dcf19a9
4
+ data.tar.gz: 56d1bd1e166613184652b00ede70f25ea9371285be99addc463e44fd28236a4b
5
5
  SHA512:
6
- metadata.gz: 202a0c186b344d6cc058d0446351bf380a251f42e476c71d430105ac1527a7af68f733a8c19b88edf09a315e1857e35ca23cbfd72ffed53ebb6011ebb0ee8389
7
- data.tar.gz: 9aa19b0b04f8a4e2313c1581c58c1b484679a5b82adc8a698c458ab4f476bae04962adc529d9029e36f1c4554c4a7839e0584847e50226bc2ce05f15c3320d13
6
+ metadata.gz: 8310d74f6bde92cc9f0d367751bb8ddfc075abb5e49aa281b5e0a6f6aadd6b8c1eea9f5f80e329afab340d30ab4189e15363c8be431f8bd9a8d28bbf16e1ec8d
7
+ data.tar.gz: 1f691fdd8dd686c860392abdeb7dadcb01771a197b48cba418a8a8555fa76a851255fa93d53f5eefc19ae3ffa3e0bb920584e19fcc15c6db96da1ee397a4545f
@@ -0,0 +1,44 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ require "dependabot/shared_helpers"
7
+
8
+ module Dependabot
9
+ module GithubActions
10
+ module ContainingBranchFinder
11
+ extend T::Sig
12
+
13
+ # A missing commit has no containing branch, so callers can handle it like
14
+ # an empty branch lookup without masking unrelated subprocess failures.
15
+ COMMIT_NOT_FOUND_REGEX = T.let(
16
+ /no such commit|malformed object name|bad object|not a valid object name/i,
17
+ Regexp
18
+ )
19
+
20
+ sig { params(sha: String).returns(T.nilable(String)) }
21
+ def self.find(sha)
22
+ branches_including_ref = SharedHelpers.run_shell_command(
23
+ "git branch --remotes --contains #{sha}",
24
+ fingerprint: "git branch --remotes --contains <sha>"
25
+ ).split("\n").map { |branch| branch.strip.gsub("origin/", "") }
26
+ return if branches_including_ref.empty?
27
+
28
+ current_branch = branches_including_ref.find { |branch| branch.start_with?("HEAD -> ") }
29
+
30
+ if current_branch
31
+ current_branch.delete_prefix("HEAD -> ")
32
+ elsif branches_including_ref.size > 1
33
+ raise "Multiple ambiguous branches (#{branches_including_ref.join(', ')}) include #{sha}!"
34
+ else
35
+ branches_including_ref.first
36
+ end
37
+ rescue SharedHelpers::HelperSubprocessFailed => e
38
+ raise unless e.message.match?(COMMIT_NOT_FOUND_REGEX)
39
+
40
+ nil
41
+ end
42
+ end
43
+ end
44
+ end
@@ -8,6 +8,7 @@ require "time"
8
8
 
9
9
  require "dependabot/errors"
10
10
  require "dependabot/git_tag_with_detail"
11
+ require "dependabot/github_actions/containing_branch_finder"
11
12
  require "dependabot/github_actions/helpers"
12
13
  require "dependabot/github_actions/requirement"
13
14
  require "dependabot/github_actions/update_checker"
@@ -224,7 +225,9 @@ module Dependabot
224
225
  SharedHelpers.run_shell_command("git clone --no-recurse-submodules #{url} #{repo_contents_path}")
225
226
 
226
227
  Dir.chdir(repo_contents_path) do
227
- ref_branch = find_container_branch(T.must(git_commit_checker.dependency_source_details&.ref))
228
+ ref_branch = ContainingBranchFinder.find(
229
+ T.must(git_commit_checker.dependency_source_details&.ref)
230
+ )
228
231
  git_commit_checker.head_commit_for_local_branch(ref_branch) if ref_branch
229
232
  end
230
233
  end
@@ -234,27 +237,6 @@ module Dependabot
234
237
  )
235
238
  end
236
239
 
237
- sig { params(sha: String).returns(T.nilable(String)) }
238
- def find_container_branch(sha)
239
- branches_including_ref = SharedHelpers.run_shell_command(
240
- "git branch --remotes --contains #{sha}",
241
- fingerprint: "git branch --remotes --contains <sha>"
242
- ).split("\n").map { |branch| branch.strip.gsub("origin/", "") }
243
- return if branches_including_ref.empty?
244
-
245
- current_branch = branches_including_ref.find { |branch| branch.start_with?("HEAD -> ") }
246
-
247
- if current_branch
248
- current_branch.delete_prefix("HEAD -> ")
249
- elsif branches_including_ref.size > 1
250
- # If there are multiple non default branches including the pinned SHA,
251
- # then it's unclear how we should proceed
252
- raise "Multiple ambiguous branches (#{branches_including_ref.join(', ')}) include #{sha}!"
253
- else
254
- branches_including_ref.first
255
- end
256
- end
257
-
258
240
  sig do
259
241
  params(tags: T::Array[T::Hash[Symbol, T.untyped]]).returns(T.nilable(T::Hash[Symbol, T.untyped]))
260
242
  end
@@ -345,7 +345,7 @@ module Dependabot
345
345
 
346
346
  sig { returns(T.nilable(T.any(Dependabot::Version, String))) }
347
347
  def current_version
348
- return dependency.source_details(allowed_types: ["git"])&.fetch(:ref) if release_type_sha?
348
+ return dependency.source_string("ref", allowed_types: ["git"]) if release_type_sha?
349
349
 
350
350
  T.let(dependency.numeric_version, T.nilable(Dependabot::Version))
351
351
  end
@@ -5,6 +5,7 @@ require "sorbet-runtime"
5
5
 
6
6
  require "dependabot/errors"
7
7
  require "dependabot/github_actions/constants"
8
+ require "dependabot/github_actions/containing_branch_finder"
8
9
  require "dependabot/github_actions/requirement"
9
10
  require "dependabot/github_actions/version"
10
11
  require "dependabot/update_checkers"
@@ -130,7 +131,9 @@ module Dependabot
130
131
  SharedHelpers.run_shell_command("git clone --no-recurse-submodules #{url} #{repo_contents_path}")
131
132
 
132
133
  Dir.chdir(repo_contents_path) do
133
- ref_branch = find_container_branch(T.must(git_commit_checker.dependency_source_details&.ref))
134
+ ref_branch = ContainingBranchFinder.find(
135
+ T.must(git_commit_checker.dependency_source_details&.ref)
136
+ )
134
137
  git_commit_checker.head_commit_for_local_branch(ref_branch) if ref_branch
135
138
  end
136
139
  end
@@ -198,26 +201,6 @@ module Dependabot
198
201
  dependency_source_details: nil
199
202
  )
200
203
  end
201
-
202
- sig { params(sha: String).returns(T.nilable(String)) }
203
- def find_container_branch(sha)
204
- branches_including_ref = SharedHelpers.run_shell_command(
205
- "git branch --remotes --contains #{sha}",
206
- fingerprint: "git branch --remotes --contains <sha>"
207
- ).split("\n").map { |branch| branch.strip.gsub("origin/", "") }
208
- return if branches_including_ref.empty?
209
-
210
- current_branch = branches_including_ref.find { |branch| branch.start_with?("HEAD -> ") }
211
-
212
- if current_branch
213
- current_branch.delete_prefix("HEAD -> ")
214
- elsif branches_including_ref.size > 1
215
- # If there are multiple non default branches including the pinned SHA, then it's unclear how we should proceed
216
- raise "Multiple ambiguous branches (#{branches_including_ref.join(', ')}) include #{sha}!"
217
- else
218
- branches_including_ref.first
219
- end
220
- end
221
204
  end
222
205
  end
223
206
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-github_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.388.0
4
+ version: 0.389.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.388.0
18
+ version: 0.389.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.388.0
25
+ version: 0.389.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -243,6 +243,7 @@ extra_rdoc_files: []
243
243
  files:
244
244
  - lib/dependabot/github_actions.rb
245
245
  - lib/dependabot/github_actions/constants.rb
246
+ - lib/dependabot/github_actions/containing_branch_finder.rb
246
247
  - lib/dependabot/github_actions/file_fetcher.rb
247
248
  - lib/dependabot/github_actions/file_parser.rb
248
249
  - lib/dependabot/github_actions/file_updater.rb
@@ -259,7 +260,7 @@ licenses:
259
260
  - MIT
260
261
  metadata:
261
262
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
262
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.388.0
263
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.389.0
263
264
  rdoc_options: []
264
265
  require_paths:
265
266
  - lib