Class: Dependabot::GoModules::FileUpdater::GoModUpdater

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/go_modules/file_updater/go_mod_updater.rb

Constant Summary collapse

RESOLVABILITY_ERROR_REGEXES =
T.let([
  # The checksum in go.sum does not match the downloaded content
  /verifying .*: checksum mismatch/,
  /go(?: get)?: .*: go.mod has post-v\d+ module path/,
  # The Go tool is suggesting the user should run go mod tidy
  /go mod tidy/,
  # Something wrong in the chain of go.mod/go.sum files
  # These are often fixable with go mod tidy too.
  /no required module provides package/,
  /missing go\.sum entry for module providing package/,
  /malformed module path/,
  /used for two different module paths/,
  # https://github.com/golang/go/issues/56494
  /can't find reason for requirement on/,
  # import path doesn't exist
  /package \S+ is not in GOROOT/
].freeze, T::Array[Regexp])
REPO_RESOLVABILITY_ERROR_REGEXES =
T.let([
  /fatal: The remote end hung up unexpectedly/,
  /repository '.+' not found/,
  %r{net/http: TLS handshake timeout},
  # (Private) module could not be fetched
  /go(?: get)?: .*: git (fetch|ls-remote) .*: exit status 128/m,
  # (Private) module could not be found
  /cannot find module providing package/,
  # Package in module was likely renamed or removed
  /module .* found \(.*\), but does not contain package/m,
  # Package pseudo-version does not match the version-control metadata
  # https://golang.google.cn/doc/go1.13#version-validation
  /go(?: get)?: .*: invalid pseudo-version/m,
  # Package does not exist, has been pulled or cannot be reached due to
  # auth problems with either git or the go proxy
  /go(?: get)?: .*: unknown revision/m,
  # Package pointing to a proxy that 404s
  /go(?: get)?: .*: unrecognized import path/m
].freeze, T::Array[Regexp])
MODULE_PATH_MISMATCH_REGEXES =
T.let([
  /go(?: get)?: ([^@\s]+)(?:@[^\s]+)?: .* has non-.* module path "(.*)" at/,
  /go(?: get)?: ([^@\s]+)(?:@[^\s]+)?: .* unexpected module path "(.*)"/,
  /go(?: get)?: ([^@\s]+)(?:@[^\s]+)?:? .* declares its path as: ([\S]*)/m
].freeze, T::Array[Regexp])
OUT_OF_DISK_REGEXES =
T.let([
  %r{input/output error},
  /no space left on device/,
  /Out of diskspace/
].freeze, T::Array[Regexp])
GO_MOD_VERSION =
/^go 1\.\d+(\.\d+)?$/

Instance Method Summary collapse

Constructor Details

#initialize(dependencies:, dependency_files:, credentials:, repo_contents_path:, directory:, options:) ⇒ GoModUpdater

Returns a new instance of GoModUpdater.



81
82
83
84
85
86
87
88
89
90
91
# File 'lib/dependabot/go_modules/file_updater/go_mod_updater.rb', line 81

def initialize(dependencies:, dependency_files:, credentials:, repo_contents_path:,
               directory:, options:)
  @dependencies = dependencies
  @dependency_files = dependency_files
  @credentials = credentials
  @repo_contents_path = repo_contents_path
  @directory = directory
  @tidy = T.let(options.fetch(:tidy, false), T::Boolean)
  @vendor = T.let(options.fetch(:vendor, false), T::Boolean)
  @goprivate = T.let(options.fetch(:goprivate), T.nilable(String))
end

Instance Method Details

#updated_go_mod_contentObject



94
95
96
# File 'lib/dependabot/go_modules/file_updater/go_mod_updater.rb', line 94

def updated_go_mod_content
  updated_files[:go_mod]
end

#updated_go_sum_contentObject



99
100
101
# File 'lib/dependabot/go_modules/file_updater/go_mod_updater.rb', line 99

def updated_go_sum_content
  updated_files[:go_sum]
end