Class: RuboCop::ChangedFiles Private

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/changed_files.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Lists the files that differ from a git revision, for --changed.

Shelling out to git keeps RuboCop free of a version control dependency, and means the answer is exactly what git would give on the command line.

Constant Summary collapse

DEFAULT_REVISION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'HEAD'
FILESYSTEM_ENCODING =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Encoding.find('filesystem')

Instance Method Summary collapse

Constructor Details

#initialize(revision = nil) ⇒ ChangedFiles

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ChangedFiles.



16
17
18
# File 'lib/rubocop/changed_files.rb', line 16

def initialize(revision = nil)
  @revision = revision || DEFAULT_REVISION
end

Instance Method Details

#pathsSet<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Files that were added or modified since the revision, as absolute paths. Deleted files are left out - there is nothing left to inspect - and untracked files are included, since a file that is new to the working tree has changed as surely as one git already knows about.

Returns:



26
27
28
29
30
# File 'lib/rubocop/changed_files.rb', line 26

def paths
  root = repository_root

  (modified_paths + untracked_paths).to_set { |path| File.expand_path(path, root) }
end