Class: Dependabot::FileUpdaters::VendorUpdater
- Inherits:
-
Object
- Object
- Dependabot::FileUpdaters::VendorUpdater
- Defined in:
- lib/dependabot/file_updaters/vendor_updater.rb
Instance Method Summary collapse
-
#initialize(repo_contents_path:, vendor_dir:) ⇒ VendorUpdater
constructor
A new instance of VendorUpdater.
-
#updated_vendor_cache_files(base_directory:) ⇒ Array<Dependabot::DependencyFile>
Returns changed files in the vendor/cache folder.
Constructor Details
#initialize(repo_contents_path:, vendor_dir:) ⇒ VendorUpdater
Returns a new instance of VendorUpdater.
8 9 10 11 |
# File 'lib/dependabot/file_updaters/vendor_updater.rb', line 8 def initialize(repo_contents_path:, vendor_dir:) @repo_contents_path = repo_contents_path @vendor_dir = vendor_dir end |
Instance Method Details
#updated_vendor_cache_files(base_directory:) ⇒ Array<Dependabot::DependencyFile>
Returns changed files in the vendor/cache folder
17 18 19 20 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/file_updaters/vendor_updater.rb', line 17 def updated_vendor_cache_files(base_directory:) return [] unless repo_contents_path && vendor_dir Dir.chdir(repo_contents_path) do relative_dir = vendor_dir.sub("#{repo_contents_path}/", "") status = SharedHelpers.run_shell_command( "git status --untracked-files=all --porcelain=v1 #{relative_dir}" ) changed_paths = status.split("\n").map { |l| l.split(" ") } changed_paths.map do |type, path| deleted = type == "D" encoding = "" encoded_content = File.read(path) unless deleted if binary_file?(path) encoding = Dependabot::DependencyFile::ContentEncoding::BASE64 encoded_content = Base64.encode64(encoded_content) unless deleted end Dependabot::DependencyFile.new( name: path, content: encoded_content, directory: base_directory, deleted: deleted, content_encoding: encoding ) end end end |