dependabot-common 0.315.0 → 0.317.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8d358807ceadc833ed82dcedc73266e3561d9b717ce53ae649ca51000c69312
|
4
|
+
data.tar.gz: d31ca9ca6aa26c1547bf9670a5addd1010d14731aa1f86cb42f58393aae945c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2cac731eb951f4c7bf1f7756f8024593105964a0c09270415d5af834147807f979c8372a1b904f38e517c9725a76020e5f51d258bc21a2ac1a99459d2abc1ab
|
7
|
+
data.tar.gz: 0cadb251db30a331dead18251239b36862fa6c113f645e9300e4365903262f4fcf7816da49ba937aaf1552f0362879f9907c3e7c12fdd2e80b30efa73c5c85ac
|
@@ -100,6 +100,17 @@ module Dependabot
|
|
100
100
|
local_repo_git_metadata_fetcher.head_commit_for_ref_sha(T.must(ref))
|
101
101
|
end
|
102
102
|
|
103
|
+
sig { returns(Excon::Response) }
|
104
|
+
def ref_details_for_pinned_ref
|
105
|
+
T.must(T.let(
|
106
|
+
GitMetadataFetcher.new(
|
107
|
+
url: dependency.source_details&.fetch(:url, nil),
|
108
|
+
credentials: credentials
|
109
|
+
).ref_details_for_pinned_ref(ref_pinned),
|
110
|
+
T.nilable(Excon::Response)
|
111
|
+
))
|
112
|
+
end
|
113
|
+
|
103
114
|
sig { params(ref: String).returns(T::Boolean) }
|
104
115
|
def ref_looks_like_commit_sha?(ref)
|
105
116
|
ref.match?(/^[0-9a-f]{6,40}$/)
|
@@ -618,6 +629,12 @@ module Dependabot
|
|
618
629
|
T.nilable(Dependabot::GitMetadataFetcher)
|
619
630
|
)
|
620
631
|
end
|
632
|
+
|
633
|
+
sig { returns(String) }
|
634
|
+
def ref_pinned
|
635
|
+
dependency.source_details&.fetch(:ref, nil) ||
|
636
|
+
dependency.source_details&.fetch(:branch, nil) || "HEAD"
|
637
|
+
end
|
621
638
|
end
|
622
639
|
# rubocop:enable Metrics/ClassLength
|
623
640
|
end
|
@@ -5,7 +5,7 @@ require "excon"
|
|
5
5
|
require "open3"
|
6
6
|
require "ostruct"
|
7
7
|
require "sorbet-runtime"
|
8
|
-
|
8
|
+
require "tmpdir"
|
9
9
|
require "dependabot/errors"
|
10
10
|
require "dependabot/git_ref"
|
11
11
|
require "dependabot/git_tag_with_detail"
|
@@ -118,6 +118,37 @@ module Dependabot
|
|
118
118
|
result_lines
|
119
119
|
end
|
120
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
|
+
|
147
|
+
sig { params(ref: String).returns(Excon::Response) }
|
148
|
+
def ref_details_for_pinned_ref(ref)
|
149
|
+
Dependabot::RegistryClient.get(url: provider_url(ref))
|
150
|
+
end
|
151
|
+
|
121
152
|
private
|
122
153
|
|
123
154
|
sig { returns(String) }
|
@@ -293,54 +324,57 @@ module Dependabot
|
|
293
324
|
raise Dependabot::GitDependenciesNotReachable, [url]
|
294
325
|
end
|
295
326
|
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
327
|
+
# Added method to fetch tags with their creation dates from a git repository. In case
|
328
|
+
# private registry is used, it will clone the repository and fetch tags with their creation dates.
|
329
|
+
sig { params(uri: String).returns(T.untyped) }
|
330
|
+
def fetch_tags_with_detail_from_git_for(uri)
|
331
|
+
uri_ending_with_git = uri
|
332
|
+
uri_ending_with_git += ".git" unless uri_ending_with_git.end_with?(".git") || skip_git_suffix(uri)
|
333
|
+
|
334
|
+
Dir.mktmpdir do |dir|
|
335
|
+
# Clone the repository into a temporary directory
|
336
|
+
clone_command = "git clone --bare #{uri_ending_with_git} #{dir}"
|
337
|
+
env = { "PATH" => ENV.fetch("PATH", nil), "GIT_TERMINAL_PROMPT" => "0" }
|
338
|
+
clone_command = SharedHelpers.escape_command(clone_command)
|
339
|
+
|
340
|
+
_stdout, stderr, process = Open3.capture3(env, clone_command)
|
341
|
+
return OpenStruct.new(body: stderr, status: 500) unless process.success?
|
342
|
+
|
343
|
+
# Change to the cloned repository directory
|
344
|
+
Dir.chdir(dir) do
|
345
|
+
# Fetch tags and their creation dates
|
346
|
+
tags_command = 'git for-each-ref --format="%(refname:short) %(creatordate:short)" refs/tags'
|
347
|
+
tags_stdout, stderr, process = Open3.capture3(env, tags_command)
|
348
|
+
|
349
|
+
return OpenStruct.new(body: stderr, status: 500) unless process.success?
|
350
|
+
|
351
|
+
# Parse and sort tags by creation date
|
352
|
+
tags = tags_stdout.lines.map do |line|
|
353
|
+
tag, date = line.strip.split(" ", 2)
|
354
|
+
{ tag: tag, date: date }
|
355
|
+
end
|
356
|
+
sorted_tags = tags.sort_by { |tag| tag[:date] }
|
357
|
+
|
358
|
+
# Format the output as a string
|
359
|
+
formatted_output = sorted_tags.map { |tag| "#{tag[:tag]} #{tag[:date]}" }.join("\n")
|
360
|
+
return OpenStruct.new(body: formatted_output, status: 200)
|
361
|
+
end
|
312
362
|
end
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
raise Dependabot::GitDependenciesNotReachable, [uri]
|
317
|
-
rescue Excon::Error::Socket, Excon::Error::Timeout
|
318
|
-
raise if uri.match?(KNOWN_HOSTS)
|
319
|
-
|
320
|
-
raise Dependabot::GitDependenciesNotReachable, [uri]
|
363
|
+
rescue Errno::ENOENT => e # Thrown when `git` isn't installed
|
364
|
+
OpenStruct.new(body: e.message, status: 500)
|
321
365
|
end
|
322
366
|
|
323
|
-
sig
|
324
|
-
|
325
|
-
|
326
|
-
|
367
|
+
sig do
|
368
|
+
params(ref: String).returns(String)
|
369
|
+
end
|
370
|
+
def provider_url(ref)
|
371
|
+
provider_url = url.gsub(/\.git$/, "")
|
327
372
|
|
328
|
-
|
329
|
-
|
330
|
-
|
373
|
+
api_url = {
|
374
|
+
github: provider_url.gsub("github.com", "api.github.com/repos")
|
375
|
+
}.freeze
|
331
376
|
|
332
|
-
|
333
|
-
stdout, stderr, process = Open3.capture3(env, command)
|
334
|
-
# package the command response like a HTTP response so error handling remains unchanged
|
335
|
-
rescue Errno::ENOENT => e # thrown when `git` isn't installed...
|
336
|
-
OpenStruct.new(body: e.message, status: 500)
|
337
|
-
else
|
338
|
-
if process.success?
|
339
|
-
OpenStruct.new(body: stdout, status: 200)
|
340
|
-
else
|
341
|
-
OpenStruct.new(body: stderr, status: 500)
|
342
|
-
end
|
343
|
-
end
|
377
|
+
"#{api_url[:github]}/commits?per_page=100&sha=#{ref}"
|
344
378
|
end
|
345
379
|
end
|
346
380
|
end
|
@@ -10,16 +10,16 @@ module Dependabot
|
|
10
10
|
sig { returns(String) }
|
11
11
|
attr_accessor :tag
|
12
12
|
|
13
|
-
sig { returns(String) }
|
13
|
+
sig { returns(T.nilable(String)) }
|
14
14
|
attr_accessor :release_date
|
15
15
|
|
16
16
|
sig do
|
17
17
|
params(
|
18
18
|
tag: String,
|
19
|
-
release_date: String
|
19
|
+
release_date: T.nilable(String)
|
20
20
|
).void
|
21
21
|
end
|
22
|
-
def initialize(tag:, release_date:)
|
22
|
+
def initialize(tag:, release_date: nil)
|
23
23
|
@tag = tag
|
24
24
|
@release_date = release_date
|
25
25
|
end
|
@@ -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
|
|
data/lib/dependabot.rb
CHANGED
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.
|
4
|
+
version: 0.317.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dependabot
|
@@ -625,7 +625,7 @@ licenses:
|
|
625
625
|
- MIT
|
626
626
|
metadata:
|
627
627
|
bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
|
628
|
-
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.
|
628
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.317.0
|
629
629
|
rdoc_options: []
|
630
630
|
require_paths:
|
631
631
|
- lib
|