dependabot-common 0.403.0 → 0.404.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: 4a258c6dc5f27617a53546bc62d7cc32fd79e45537f4f3faeab967c9e94641b8
4
- data.tar.gz: f1e203208a54733408e4b94c793185108349db7a493a0be78e2103754fabcfc5
3
+ metadata.gz: 6ec6e0ecb3de7082a8de112f55736280cc9a51e2a9ec2303fec8750a2caa26c4
4
+ data.tar.gz: e29983ea289cc624336613747d36fc4553dc97da8304d211c944d22677740cab
5
5
  SHA512:
6
- metadata.gz: 2fb50fc39f60920d8889db4720c138a13c3de8737527c0c1426934789635a9a531d2ae9436a0974dc1744d6d4955c68c5d4ff2b8f08b6431c62fda38d207bbdf
7
- data.tar.gz: 720e7093f19d80501c4bdac6819aff9e86ff61b9725df3f874729f8726437cf1ed7712e5c12bf8fab3e1ec6bb6beb115329fcd1654eec52372ccb9d92df3c5c4
6
+ metadata.gz: 25a3383b36d13350554870237535aea892bc3ee8f51d1784256c154c4ee1ab985d8bf7fc51364abf0fa5b95fd6558c62f40c75094d34599fb201a329c23cf6fc
7
+ data.tar.gz: 1bfca8d6d91cc67b83457db323dd18e67f29eb7284fccc69c609d1f2d6350420cfd0a8ee46a8ea40f0da435864c3d964e60b16692fb3129083646406012297cd
@@ -418,7 +418,7 @@ module Dependabot
418
418
  def allowed_versions(local_tags, filter_by_prefix: true)
419
419
  tags =
420
420
  local_tags
421
- .select { |t| version_tag?(t.name) && (filter_by_prefix ? matches_existing_prefix?(t.name) : true) }
421
+ .select { |t| parsable_version_tag?(t.name) && (filter_by_prefix ? matches_existing_prefix?(t.name) : true) }
422
422
  filtered = tags
423
423
  .reject { |t| tag_included_in_ignore_requirements?(t) }
424
424
  if @raise_on_ignored && filter_lower_versions(filtered).empty? && filter_lower_versions(tags).any?
@@ -594,6 +594,14 @@ module Dependabot
594
594
  tag.match?(VERSION_REGEX)
595
595
  end
596
596
 
597
+ # A tag can match VERSION_REGEX and still be rejected by the ecosystem's version class
598
+ # (e.g. `v1.2.2-python38` is not a valid PEP 440 version). Parsing such a tag raises,
599
+ # which would abort the update for the whole dependency, so treat it as a non-version tag.
600
+ sig { params(tag: String).returns(T::Boolean) }
601
+ def parsable_version_tag?(tag)
602
+ version_tag?(tag) && version_class.correct?(scan_version(tag))
603
+ end
604
+
597
605
  sig { params(tag: String).returns(T::Boolean) }
598
606
  def matches_existing_prefix?(tag)
599
607
  return true unless ref_or_branch
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "excon"
5
+ require "fileutils"
5
6
  require "open3"
6
7
  require "sorbet-runtime"
7
8
  require "tmpdir"
@@ -9,6 +10,7 @@ require "dependabot/errors"
9
10
  require "dependabot/git_ref"
10
11
  require "dependabot/git_tag_with_detail"
11
12
  require "dependabot/credential"
13
+ require "dependabot/logger"
12
14
 
13
15
  module Dependabot
14
16
  class GitMetadataFetcher
@@ -344,12 +346,10 @@ module Dependabot
344
346
  uri_ending_with_git += ".git" unless uri_ending_with_git.end_with?(".git") || skip_git_suffix(uri)
345
347
 
346
348
  Dir.mktmpdir do |dir|
347
- # Clone the repository into a temporary directory
348
- clone_command = "git clone --bare #{uri_ending_with_git} #{dir}"
349
349
  env = { "PATH" => ENV.fetch("PATH", nil), "GIT_TERMINAL_PROMPT" => "0" }
350
- clone_command = SharedHelpers.escape_command(clone_command)
351
350
 
352
- _stdout, stderr, process = Open3.capture3(env, clone_command)
351
+ # Clone the repository into a temporary directory
352
+ _stdout, stderr, process = clone_for_tag_details(env, uri_ending_with_git, dir)
353
353
  return GitResponse.new(body: stderr, status: 500) unless process.success?
354
354
 
355
355
  # Change to the cloned repository directory
@@ -376,6 +376,24 @@ module Dependabot
376
376
  GitResponse.new(body: e.message, status: 500)
377
377
  end
378
378
 
379
+ # Tag dates need only commits and tags, so skip trees and blobs: a full clone of a large
380
+ # repository can fill the disk or time out. Fall back to a full clone if the partial clone
381
+ # fails, so this never does worse than before.
382
+ sig do
383
+ params(env: T::Hash[String, T.nilable(String)], uri: String, dir: String)
384
+ .returns([String, String, Process::Status])
385
+ end
386
+ def clone_for_tag_details(env, uri, dir)
387
+ stdout, stderr, process = Open3.capture3(
388
+ env, SharedHelpers.escape_command("git clone --bare --filter=tree:0 #{uri} #{dir}")
389
+ )
390
+ return [stdout, stderr, process] if process.success?
391
+
392
+ Dependabot.logger.warn("Partial clone for tag dates failed, falling back to a full clone")
393
+ FileUtils.rm_rf(Dir.children(dir).map { |child| File.join(dir, child) })
394
+ Open3.capture3(env, SharedHelpers.escape_command("git clone --bare #{uri} #{dir}"))
395
+ end
396
+
379
397
  sig do
380
398
  params(ref: String).returns(String)
381
399
  end
@@ -715,6 +715,9 @@ module Dependabot
715
715
  else
716
716
  dependency.display_name
717
717
  end
718
+ rescue StandardError => e
719
+ suppress_error("dependency link for #{dependency.name}", e)
720
+ dependency.display_name
718
721
  end
719
722
 
720
723
  sig { params(dependency: Dependabot::Dependency).returns(String) }
@@ -746,6 +749,9 @@ module Dependabot
746
749
  msg += "\n- [Upgrade guide](#{upgrade_url(dep)})" if upgrade_url(dep)
747
750
  msg += "\n- [Commits](#{commits_url(dep)})" if commits_url(dep)
748
751
  msg
752
+ rescue StandardError => e
753
+ suppress_error("metadata links for #{dep.name}", e)
754
+ ""
749
755
  end
750
756
 
751
757
  sig { params(rows: T::Array[T::Array[String]]).returns(String) }
data/lib/dependabot.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Dependabot
5
- VERSION = "0.403.0"
5
+ VERSION = "0.404.0"
6
6
  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.403.0
4
+ version: 0.404.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -635,7 +635,7 @@ licenses:
635
635
  - MIT
636
636
  metadata:
637
637
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
638
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.403.0
638
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.404.0
639
639
  rdoc_options: []
640
640
  require_paths:
641
641
  - lib