Class: Dependabot::Composer::FileUpdater

Inherits:
FileUpdaters::Base
  • Object
show all
Defined in:
lib/dependabot/composer/file_updater.rb,
lib/dependabot/composer/file_updater/lockfile_updater.rb,
lib/dependabot/composer/file_updater/manifest_updater.rb

Defined Under Namespace

Classes: LockfileUpdater, ManifestUpdater

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.updated_files_regexObject


14
15
16
17
18
19
# File 'lib/dependabot/composer/file_updater.rb', line 14

def self.updated_files_regex
  [
    /^composer\.json$/,
    /^composer\.lock$/
  ]
end

Instance Method Details

#updated_dependency_filesObject


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

def updated_dependency_files
  updated_files = []

  if file_changed?(composer_json)
    updated_files <<
      updated_file(
        file: composer_json,
        content: updated_composer_json_content
      )
  end

  if lockfile
    updated_files <<
      updated_file(file: lockfile, content: updated_lockfile_content)
  end

  if updated_files.none? ||
     updated_files.sort_by(&:name) == dependency_files.sort_by(&:name)
    raise "No files have changed!"
  end

  updated_files
end