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/,
    /missing go\.sum entry for go\.mod file/m,
    /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,
    # Package not being referenced correctly
    /go:.*imports.*package.+is not in std/m,
    # Invalid version due to missing go.mod files at specified revision
    /go: .*: invalid version: missing .*go\.mod.* at revision/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_PARSE_ERROR_REGEXES =
T.let(
  [
    # go.mod file parsing errors
    /go: error loading go\.mod:/,
    /go\.mod:\d+: .*unknown.*/,
    /go\.mod:\d+: .*syntax error.*/,
    /go\.mod:\d+: .*invalid.*/
  ].freeze,
  T::Array[Regexp]
)
GO_LANG =
"Go"
AMBIGUOUS_ERROR_MESSAGE =
/ambiguous import: found package (?<package>.*) in multiple modules/
GO_VERSION_MISMATCH =
/requires go (?<current_ver>.*) .*running go (?<req_ver>.*);/
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.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/dependabot/go_modules/file_updater/go_mod_updater.rb', line 115

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)
end

Instance Method Details

#updated_go_mod_contentObject



133
134
135
# File 'lib/dependabot/go_modules/file_updater/go_mod_updater.rb', line 133

def updated_go_mod_content
  updated_files[:go_mod]
end

#updated_go_sum_contentObject



138
139
140
# File 'lib/dependabot/go_modules/file_updater/go_mod_updater.rb', line 138

def updated_go_sum_content
  updated_files[:go_sum]
end