Module: EacGit::Local::DirtyFiles

Defined in:
lib/eac_git/local/dirty_files.rb

Constant Summary collapse

STATUS_LINE_PATTERN =
/\A(.)(.)\s(.+)\z/.freeze

Instance Method Summary collapse

Instance Method Details

#dirty?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/eac_git/local/dirty_files.rb', line 11

def dirty?
  dirty_files.any?
end

#dirty_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
18
19
20
# File 'lib/eac_git/local/dirty_files.rb', line 15

def dirty_file?(path)
  absolute_path = path.to_pathname.expand_path(root_path)
  dirty_files.any? do |df|
    df.absolute_path == absolute_path
  end
end

#dirty_filesObject



22
23
24
25
# File 'lib/eac_git/local/dirty_files.rb', line 22

def dirty_files
  command('status', '--porcelain=v1', '--untracked-files', '--no-renames')
    .execute!.each_line.map { |line| parse_status_line(line.gsub(/\n\z/, '')) }
end