Class: Dependabot::Composer::FileUpdater::LockfileUpdater

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

Instance Method Summary collapse

Constructor Details

#initialize(dependencies:, dependency_files:, credentials:) ⇒ LockfileUpdater

Returns a new instance of LockfileUpdater.


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

def initialize(dependencies:, dependency_files:, credentials:)
  @dependencies = dependencies
  @dependency_files = dependency_files
  @credentials = credentials
end

Instance Method Details

#updated_lockfile_contentObject


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

def updated_lockfile_content
  base_directory = dependency_files.first.directory
  @updated_lockfile_content ||=
    SharedHelpers.in_a_temporary_directory(base_directory) do
      write_temporary_dependency_files

      updated_content = run_update_helper.fetch("composer.lock")

      updated_content = post_process_lockfile(updated_content)
      if lockfile.content == updated_content
        raise "Expected content to change!"
      end

      updated_content
    end
rescue SharedHelpers::HelperSubprocessFailed => e
  retry_count ||= 0
  retry_count += 1
  retry if transitory_failure?(e) && retry_count <= 1
  handle_composer_errors(e)
end