Class: Dependabot::GoModules::FileUpdater

Inherits:
FileUpdaters::Base
  • Object
show all
Defined in:
lib/dependabot/go_modules/file_updater.rb,
lib/dependabot/go_modules/file_updater/go_mod_updater.rb

Defined Under Namespace

Classes: GoModUpdater

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.updated_files_regexObject


12
13
14
15
16
17
# File 'lib/dependabot/go_modules/file_updater.rb', line 12

def self.updated_files_regex
  [
    /^go\.mod$/,
    /^go\.sum$/
  ]
end

Instance Method Details

#updated_dependency_filesObject


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/dependabot/go_modules/file_updater.rb', line 19

def updated_dependency_files
  updated_files = []

  if go_mod && file_changed?(go_mod)
    updated_files <<
      updated_file(
        file: go_mod,
        content: file_updater.updated_go_mod_content
      )

    if go_sum && go_sum.content != file_updater.updated_go_sum_content
      updated_files <<
        updated_file(
          file: go_sum,
          content: file_updater.updated_go_sum_content
        )
    end
  end

  raise "No files changed!" if updated_files.none?

  updated_files
end