dependabot-common 0.314.0 → 0.316.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: 75665e6e5f16e2e104b7415ff2f557508d03f394e8f9de6a5f841f4352e1484e
4
- data.tar.gz: 61f9095c642362351d1381f1f9d3f5a26c13d3b24fb1841046b3682c6a85aaa6
3
+ metadata.gz: 96bdb5c59d32f26540da409a5dc9052431575832324c353ecb5b6f385962ff8c
4
+ data.tar.gz: 17ee865c4fe6825bb6e01b3f42e7255e1a283b35bf495a55d570977f529970c8
5
5
  SHA512:
6
- metadata.gz: bd09436156631884d91cd670497ca6d033ee4cb2927db598d0348f78af77f4d7bc1626ccd6ea36e051f900ad9b5ad4299f4c49e5cb4308a6203e99861c7cd458
7
- data.tar.gz: f2a87eed835ec64c46769dadae2ec093fc8d6b9c8a004c40d3c65ed55a824ebdd2a402165d640d83dad757a0d34473f3b92d92d8ffd1aa99a2af0d734af9fdff
6
+ metadata.gz: 326849c6620a3a1c87c6f32005010ccfb4bb8dad03bce1edc5c1944f19630a5c2c10119d965055f5c94327dcfec3fab22a09968675c9c4889c38a1f67857c960
7
+ data.tar.gz: 445ea4329399825e8637a325f2e41e7515732a480a80dd4961c4571ef22469bc361c29c0720a9907a24d661da507eef24f0e515c511290e49386f8b144893dcb
@@ -297,7 +297,7 @@ module Dependabot
297
297
  sig { params(url: String).returns(Excon::Response) }
298
298
  def get(url)
299
299
  response = Excon.get(
300
- URI::DEFAULT_PARSER.escape(url),
300
+ URI::RFC2396_PARSER.escape(url),
301
301
  user: credentials&.fetch("username", nil),
302
302
  password: credentials&.fetch("password", nil),
303
303
  # Setting to false to prevent Excon retries, use BitbucketWithRetries for retries.
@@ -1,8 +1,10 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "stringio"
4
+ require "ostruct"
5
5
  require "sorbet-runtime"
6
+ require "stringio"
7
+
6
8
  require "dependabot/config"
7
9
  require "dependabot/dependency_file"
8
10
  require "dependabot/source"
@@ -234,6 +234,13 @@ module Dependabot
234
234
  tags[-1]&.name
235
235
  end
236
236
 
237
+ sig { params(tags: T::Array[Dependabot::GitRef]).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
238
+ def max_local_tag(tags)
239
+ max_version_tag = tags.max_by { |t| version_from_tag(t) }
240
+
241
+ to_local_tag(max_version_tag)
242
+ end
243
+
237
244
  private
238
245
 
239
246
  sig { returns(Dependabot::Dependency) }
@@ -255,13 +262,6 @@ module Dependabot
255
262
  max_local_tag(select_lower_precision(tags))
256
263
  end
257
264
 
258
- sig { params(tags: T::Array[Dependabot::GitRef]).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
259
- def max_local_tag(tags)
260
- max_version_tag = tags.max_by { |t| version_from_tag(t) }
261
-
262
- to_local_tag(max_version_tag)
263
- end
264
-
265
265
  # Find the latest version with the same precision as the pinned version.
266
266
  sig { params(tags: T::Array[Dependabot::GitRef]).returns(T::Array[Dependabot::GitRef]) }
267
267
  def select_matching_existing_precision(tags)
@@ -3,8 +3,9 @@
3
3
 
4
4
  require "excon"
5
5
  require "open3"
6
+ require "ostruct"
6
7
  require "sorbet-runtime"
7
-
8
+ require "tmpdir"
8
9
  require "dependabot/errors"
9
10
  require "dependabot/git_ref"
10
11
  require "dependabot/git_tag_with_detail"
@@ -117,6 +118,32 @@ module Dependabot
117
118
  result_lines
118
119
  end
119
120
 
121
+ sig { params(uri: String).returns(String) }
122
+ def fetch_tags_with_detail(uri)
123
+ response_with_git = fetch_tags_with_detail_from_git_for(uri)
124
+ return response_with_git.body if response_with_git.status == 200
125
+
126
+ raise Dependabot::GitDependenciesNotReachable, [uri] unless uri.match?(KNOWN_HOSTS)
127
+
128
+ if response_with_git.status < 400
129
+ raise "Unexpected response: #{response_with_git.status} - #{response_with_git.body}"
130
+ end
131
+
132
+ if uri.match?(/github\.com/i)
133
+ response = response_with_git.data
134
+ response[:response_headers] = response[:headers] unless response.nil?
135
+ raise Octokit::Error.from_response(response)
136
+ end
137
+
138
+ raise "Server error at #{uri}: #{response_with_git.body}" if response_with_git.status >= 500
139
+
140
+ raise Dependabot::GitDependenciesNotReachable, [uri]
141
+ rescue Excon::Error::Socket, Excon::Error::Timeout
142
+ raise if uri.match?(KNOWN_HOSTS)
143
+
144
+ raise Dependabot::GitDependenciesNotReachable, [uri]
145
+ end
146
+
120
147
  private
121
148
 
122
149
  sig { returns(String) }
@@ -292,54 +319,44 @@ module Dependabot
292
319
  raise Dependabot::GitDependenciesNotReachable, [url]
293
320
  end
294
321
 
295
- sig { params(uri: String).returns(String) }
296
- def fetch_tags_with_detail(uri)
297
- response = fetch_raw_upload_pack_for(uri)
298
- return response.body if response.status == 200
299
-
300
- response_with_git = fetch_tags_with_detail_from_git_for(uri)
301
- return response_with_git.body if response_with_git.status == 200
302
-
303
- raise Dependabot::GitDependenciesNotReachable, [uri] unless uri.match?(KNOWN_HOSTS)
304
-
305
- raise "Unexpected response: #{response.status} - #{response.body}" if response.status < 400
306
-
307
- if uri.match?(/github\.com/i)
308
- response = response.data
309
- response[:response_headers] = response[:headers]
310
- raise Octokit::Error.from_response(response)
311
- end
312
-
313
- raise "Server error at #{uri}: #{response.body}" if response.status >= 500
314
-
315
- raise Dependabot::GitDependenciesNotReachable, [uri]
316
- rescue Excon::Error::Socket, Excon::Error::Timeout
317
- raise if uri.match?(KNOWN_HOSTS)
318
-
319
- raise Dependabot::GitDependenciesNotReachable, [uri]
320
- end
321
-
322
+ # Added method to fetch tags with their creation dates from a git repository. In case
323
+ # private registry is used, it will clone the repository and fetch tags with their creation dates.
322
324
  sig { params(uri: String).returns(T.untyped) }
323
325
  def fetch_tags_with_detail_from_git_for(uri)
324
- complete_uri = uri
325
- complete_uri += ".git" unless complete_uri.end_with?(".git") || skip_git_suffix(uri)
326
-
327
- env = { "PATH" => ENV.fetch("PATH", nil), "GIT_TERMINAL_PROMPT" => "0" }
328
- command = "git for-each-ref --format=\"%(refname:short) %(creatordate:short)\" refs/tags #{complete_uri}"
329
- command = SharedHelpers.escape_command(command)
330
-
331
- begin
332
- stdout, stderr, process = Open3.capture3(env, command)
333
- # package the command response like a HTTP response so error handling remains unchanged
334
- rescue Errno::ENOENT => e # thrown when `git` isn't installed...
335
- OpenStruct.new(body: e.message, status: 500)
336
- else
337
- if process.success?
338
- OpenStruct.new(body: stdout, status: 200)
339
- else
340
- OpenStruct.new(body: stderr, status: 500)
326
+ uri_ending_with_git = uri
327
+ uri_ending_with_git += ".git" unless uri_ending_with_git.end_with?(".git") || skip_git_suffix(uri)
328
+
329
+ Dir.mktmpdir do |dir|
330
+ # Clone the repository into a temporary directory
331
+ clone_command = "git clone --bare #{uri_ending_with_git} #{dir}"
332
+ env = { "PATH" => ENV.fetch("PATH", nil), "GIT_TERMINAL_PROMPT" => "0" }
333
+ clone_command = SharedHelpers.escape_command(clone_command)
334
+
335
+ _stdout, stderr, process = Open3.capture3(env, clone_command)
336
+ return OpenStruct.new(body: stderr, status: 500) unless process.success?
337
+
338
+ # Change to the cloned repository directory
339
+ Dir.chdir(dir) do
340
+ # Fetch tags and their creation dates
341
+ tags_command = 'git for-each-ref --format="%(refname:short) %(creatordate:short)" refs/tags'
342
+ tags_stdout, stderr, process = Open3.capture3(env, tags_command)
343
+
344
+ return OpenStruct.new(body: stderr, status: 500) unless process.success?
345
+
346
+ # Parse and sort tags by creation date
347
+ tags = tags_stdout.lines.map do |line|
348
+ tag, date = line.strip.split(" ", 2)
349
+ { tag: tag, date: date }
350
+ end
351
+ sorted_tags = tags.sort_by { |tag| tag[:date] }
352
+
353
+ # Format the output as a string
354
+ formatted_output = sorted_tags.map { |tag| "#{tag[:tag]} #{tag[:date]}" }.join("\n")
355
+ return OpenStruct.new(body: formatted_output, status: 200)
341
356
  end
342
357
  end
358
+ rescue Errno::ENOENT => e # Thrown when `git` isn't installed
359
+ OpenStruct.new(body: e.message, status: 500)
343
360
  end
344
361
  end
345
362
  end
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "excon"
5
+ require "ostruct"
5
6
  require "sorbet-runtime"
6
7
 
7
8
  require "dependabot/clients/github_with_retries"
@@ -1,6 +1,7 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "ostruct"
4
5
  require "sorbet-runtime"
5
6
 
6
7
  require "dependabot/credential"
@@ -23,6 +23,7 @@ module Dependabot
23
23
  url: T.nilable(String),
24
24
  package_type: T.nilable(String),
25
25
  language: T.nilable(Dependabot::Package::PackageLanguage),
26
+ tag: T.nilable(String),
26
27
  details: T::Hash[String, T.untyped]
27
28
  ).void
28
29
  end
@@ -36,6 +37,7 @@ module Dependabot
36
37
  url: nil,
37
38
  package_type: nil,
38
39
  language: nil,
40
+ tag: nil,
39
41
  details: {}
40
42
  )
41
43
  @version = T.let(version, Dependabot::Version)
@@ -47,6 +49,7 @@ module Dependabot
47
49
  @url = T.let(url, T.nilable(String))
48
50
  @package_type = T.let(package_type, T.nilable(String))
49
51
  @language = T.let(language, T.nilable(Dependabot::Package::PackageLanguage))
52
+ @tag = T.let(tag, T.nilable(String))
50
53
  @details = T.let(details, T::Hash[String, T.untyped])
51
54
  end
52
55
 
@@ -77,6 +80,9 @@ module Dependabot
77
80
  sig { returns(T.nilable(Dependabot::Package::PackageLanguage)) }
78
81
  attr_reader :language
79
82
 
83
+ sig { returns(T.nilable(String)) }
84
+ attr_reader :tag
85
+
80
86
  sig { returns(T::Hash[String, T.untyped]) }
81
87
  attr_reader :details
82
88
 
@@ -0,0 +1,80 @@
1
+ # typed: strong
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+ require "dependabot/pull_request_creator/branch_namer/base"
6
+
7
+ module Dependabot
8
+ class PullRequestCreator
9
+ class BranchNamer
10
+ class MultiEcosystemStrategy < Base
11
+ extend T::Sig
12
+
13
+ sig do
14
+ params(
15
+ dependencies: T::Array[Dependabot::Dependency],
16
+ files: T::Array[Dependabot::DependencyFile],
17
+ target_branch: T.nilable(String),
18
+ includes_security_fixes: T::Boolean,
19
+ multi_ecosystem_name: String,
20
+ separator: String,
21
+ prefix: String,
22
+ max_length: T.nilable(Integer)
23
+ )
24
+ .void
25
+ end
26
+ def initialize(dependencies:, files:, target_branch:, includes_security_fixes:, multi_ecosystem_name:,
27
+ separator: "/", prefix: "dependabot", max_length: nil)
28
+ super(
29
+ dependencies: dependencies,
30
+ files: files,
31
+ target_branch: target_branch,
32
+ separator: separator,
33
+ prefix: prefix,
34
+ max_length: max_length,
35
+ )
36
+
37
+ @multi_ecosystem_name = multi_ecosystem_name
38
+ @includes_security_fixes = includes_security_fixes
39
+ end
40
+
41
+ sig { override.returns(String) }
42
+ def new_branch_name
43
+ sanitize_branch_name(File.join(prefixes, group_name_with_dependency_digest))
44
+ end
45
+
46
+ private
47
+
48
+ sig { returns(String) }
49
+ attr_reader :multi_ecosystem_name
50
+
51
+ sig { returns(T::Array[String]) }
52
+ def prefixes
53
+ [
54
+ prefix,
55
+ target_branch
56
+ ].compact
57
+ end
58
+
59
+ sig { returns(String) }
60
+ def group_name_with_dependency_digest
61
+ if @includes_security_fixes
62
+ "group-security-#{multi_ecosystem_name}-#{dependency_digest}"
63
+ else
64
+ "#{multi_ecosystem_name}-#{dependency_digest}"
65
+ end
66
+ end
67
+
68
+ sig { returns(T.nilable(String)) }
69
+ def dependency_digest
70
+ @dependency_digest ||= T.let(
71
+ Digest::MD5.hexdigest(dependencies.map do |dependency|
72
+ "#{dependency.name}-#{dependency.removed? ? 'removed' : dependency.version}"
73
+ end.sort.join(",")).slice(0, 10),
74
+ T.nilable(String)
75
+ )
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -8,6 +8,7 @@ require "dependabot/metadata_finders"
8
8
  require "dependabot/pull_request_creator"
9
9
  require "dependabot/pull_request_creator/branch_namer/solo_strategy"
10
10
  require "dependabot/pull_request_creator/branch_namer/dependency_group_strategy"
11
+ require "dependabot/pull_request_creator/branch_namer/multi_ecosystem_strategy"
11
12
 
12
13
  module Dependabot
13
14
  class PullRequestCreator
@@ -38,6 +39,9 @@ module Dependabot
38
39
  sig { returns(T::Boolean) }
39
40
  attr_reader :includes_security_fixes
40
41
 
42
+ sig { returns(T.nilable(String)) }
43
+ attr_reader :multi_ecosystem_name
44
+
41
45
  sig do
42
46
  params(
43
47
  dependencies: T::Array[Dependabot::Dependency],
@@ -47,12 +51,13 @@ module Dependabot
47
51
  separator: String,
48
52
  prefix: String,
49
53
  max_length: T.nilable(Integer),
50
- includes_security_fixes: T::Boolean
54
+ includes_security_fixes: T::Boolean,
55
+ multi_ecosystem_name: T.nilable(String)
51
56
  )
52
57
  .void
53
58
  end
54
59
  def initialize(dependencies:, files:, target_branch:, dependency_group: nil, separator: "/",
55
- prefix: "dependabot", max_length: nil, includes_security_fixes: false)
60
+ prefix: "dependabot", max_length: nil, includes_security_fixes: false, multi_ecosystem_name: nil)
56
61
  @dependencies = dependencies
57
62
  @files = files
58
63
  @target_branch = target_branch
@@ -61,6 +66,7 @@ module Dependabot
61
66
  @prefix = prefix
62
67
  @max_length = max_length
63
68
  @includes_security_fixes = includes_security_fixes
69
+ @multi_ecosystem_name = multi_ecosystem_name
64
70
  end
65
71
 
66
72
  sig { returns(String) }
@@ -73,30 +79,56 @@ module Dependabot
73
79
  sig { returns(Dependabot::PullRequestCreator::BranchNamer::Base) }
74
80
  def strategy
75
81
  @strategy ||= T.let(
76
- if dependency_group.nil?
77
- SoloStrategy.new(
78
- dependencies: dependencies,
79
- files: files,
80
- target_branch: target_branch,
81
- separator: separator,
82
- prefix: prefix,
83
- max_length: max_length
84
- )
82
+ if multi_ecosystem_name
83
+ build_multi_ecosystem_strategy
84
+ elsif dependency_group.nil?
85
+ build_solo_strategy
85
86
  else
86
- DependencyGroupStrategy.new(
87
- dependencies: dependencies,
88
- files: files,
89
- target_branch: target_branch,
90
- dependency_group: T.must(dependency_group),
91
- includes_security_fixes: includes_security_fixes,
92
- separator: separator,
93
- prefix: prefix,
94
- max_length: max_length
95
- )
87
+ build_dependency_group_strategy
96
88
  end,
97
89
  T.nilable(Dependabot::PullRequestCreator::BranchNamer::Base)
98
90
  )
99
91
  end
92
+
93
+ sig { returns(Dependabot::PullRequestCreator::BranchNamer::MultiEcosystemStrategy) }
94
+ def build_multi_ecosystem_strategy
95
+ MultiEcosystemStrategy.new(
96
+ dependencies: dependencies,
97
+ files: files,
98
+ target_branch: target_branch,
99
+ includes_security_fixes: includes_security_fixes,
100
+ separator: separator,
101
+ prefix: prefix,
102
+ max_length: max_length,
103
+ multi_ecosystem_name: T.must(multi_ecosystem_name)
104
+ )
105
+ end
106
+
107
+ sig { returns(Dependabot::PullRequestCreator::BranchNamer::SoloStrategy) }
108
+ def build_solo_strategy
109
+ SoloStrategy.new(
110
+ dependencies: dependencies,
111
+ files: files,
112
+ target_branch: target_branch,
113
+ separator: separator,
114
+ prefix: prefix,
115
+ max_length: max_length
116
+ )
117
+ end
118
+
119
+ sig { returns(Dependabot::PullRequestCreator::BranchNamer::DependencyGroupStrategy) }
120
+ def build_dependency_group_strategy
121
+ DependencyGroupStrategy.new(
122
+ dependencies: dependencies,
123
+ files: files,
124
+ target_branch: target_branch,
125
+ dependency_group: T.must(dependency_group),
126
+ includes_security_fixes: includes_security_fixes,
127
+ separator: separator,
128
+ prefix: prefix,
129
+ max_length: max_length
130
+ )
131
+ end
100
132
  end
101
133
  end
102
134
  end
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "tmpdir"
5
- require "set"
6
5
  require "sorbet-runtime"
7
6
 
8
7
  require "dependabot/requirement"
data/lib/dependabot.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Dependabot
5
- VERSION = "0.314.0"
5
+ VERSION = "0.316.0"
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.314.0
4
+ version: 0.316.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-05-22 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: aws-sdk-codecommit
@@ -91,14 +91,14 @@ dependencies:
91
91
  requirements:
92
92
  - - "~>"
93
93
  - !ruby/object:Gem::Version
94
- version: '0.109'
94
+ version: '1.2'
95
95
  type: :runtime
96
96
  prerelease: false
97
97
  version_requirements: !ruby/object:Gem::Requirement
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '0.109'
101
+ version: '1.2'
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: faraday
104
104
  requirement: !ruby/object:Gem::Requirement
@@ -225,6 +225,20 @@ dependencies:
225
225
  - - "~>"
226
226
  - !ruby/object:Gem::Version
227
227
  version: '0.3'
228
+ - !ruby/object:Gem::Dependency
229
+ name: ostruct
230
+ requirement: !ruby/object:Gem::Requirement
231
+ requirements:
232
+ - - "~>"
233
+ - !ruby/object:Gem::Version
234
+ version: '0.6'
235
+ type: :runtime
236
+ prerelease: false
237
+ version_requirements: !ruby/object:Gem::Requirement
238
+ requirements:
239
+ - - "~>"
240
+ - !ruby/object:Gem::Version
241
+ version: '0.6'
228
242
  - !ruby/object:Gem::Dependency
229
243
  name: parser
230
244
  requirement: !ruby/object:Gem::Requirement
@@ -569,6 +583,7 @@ files:
569
583
  - lib/dependabot/pull_request_creator/branch_namer.rb
570
584
  - lib/dependabot/pull_request_creator/branch_namer/base.rb
571
585
  - lib/dependabot/pull_request_creator/branch_namer/dependency_group_strategy.rb
586
+ - lib/dependabot/pull_request_creator/branch_namer/multi_ecosystem_strategy.rb
572
587
  - lib/dependabot/pull_request_creator/branch_namer/solo_strategy.rb
573
588
  - lib/dependabot/pull_request_creator/codecommit.rb
574
589
  - lib/dependabot/pull_request_creator/commit_signer.rb
@@ -610,7 +625,7 @@ licenses:
610
625
  - MIT
611
626
  metadata:
612
627
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
613
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.314.0
628
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.316.0
614
629
  rdoc_options: []
615
630
  require_paths:
616
631
  - lib
@@ -618,14 +633,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
618
633
  requirements:
619
634
  - - ">="
620
635
  - !ruby/object:Gem::Version
621
- version: 3.1.0
636
+ version: 3.3.0
622
637
  required_rubygems_version: !ruby/object:Gem::Requirement
623
638
  requirements:
624
639
  - - ">="
625
640
  - !ruby/object:Gem::Version
626
641
  version: 3.3.7
627
642
  requirements: []
628
- rubygems_version: 3.6.3
643
+ rubygems_version: 3.6.9
629
644
  specification_version: 4
630
645
  summary: Shared code used across Dependabot Core
631
646
  test_files: []