Module: EacGit::Local::DirtyFiles

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

Constant Summary collapse

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

Instance Method Summary collapse

Instance Method Details

#dirty?Boolean

Returns:

  • (Boolean)


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

def dirty?
  dirty_files.any?
end

#dirty_file?(path) ⇒ Boolean

Returns:

  • (Boolean)


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

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



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

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