Class: Dependabot::FileUpdaters::Rust::Cargo

Inherits:
Base
  • Object
show all
Defined in:
lib/dependabot/file_updaters/rust/cargo.rb,
lib/dependabot/file_updaters/rust/cargo/lockfile_updater.rb,
lib/dependabot/file_updaters/rust/cargo/manifest_updater.rb

Defined Under Namespace

Classes: LockfileUpdater, ManifestUpdater

Instance Attribute Summary

Attributes inherited from Base

#credentials, #dependencies, #dependency_files

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Dependabot::FileUpdaters::Base

Class Method Details

.updated_files_regexObject



16
17
18
19
20
21
# File 'lib/dependabot/file_updaters/rust/cargo.rb', line 16

def self.updated_files_regex
  [
    /^Cargo\.toml$/,
    /^Cargo\.lock$/
  ]
end

Instance Method Details

#updated_dependency_filesObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dependabot/file_updaters/rust/cargo.rb', line 23

def updated_dependency_files
  # Returns an array of updated files. Only files that have been updated
  # should be returned.
  updated_files = []

  manifest_files.each do |file|
    next unless file_changed?(file)

    updated_files <<
      updated_file(
        file: file,
        content: updated_manifest_content(file)
      )
  end

  if lockfile && updated_lockfile_content != lockfile.content
    updated_files <<
      updated_file(file: lockfile, content: updated_lockfile_content)
  end

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

  updated_files
end