Sha256: a19d05bdabc9be1b22d0450d44a3f9dfe0d49e0afef6932c90df512c0d71c508

Contents?: true

Size: 493 Bytes

Versions: 23

Compression:

Stored size: 493 Bytes

Contents

class Utils

  def self.staged_files(*dirs)
    dirs = reject_missing(dirs)

    @staged_files ||= {}
    @staged_files[dirs.join(' ')] ||= `git diff --cached --name-only --diff-filter=ACM #{dirs.join(' ')} | xargs`.chomp
  end

  def self.new_files(*dirs)
    @new_files ||= {}
    @new_files[dirs.join(' ')] ||= `git status --short #{dirs.join(' ')} | grep ^A | xargs`.chomp.split("A ").join(" ")
  end

  def self.reject_missing(dirs)
    dirs.reject { |dir| !File.exist?(dir) }
  end

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
pre-commit-0.5.0 lib/pre-commit/utils.rb
pre-commit-0.4.0 lib/pre-commit/utils.rb
pre-commit-0.3.1 lib/pre-commit/utils.rb
pre-commit-0.3.0 lib/pre-commit/utils.rb
pre-commit-0.2.0 lib/pre-commit/utils.rb
pre-commit-0.1.19 lib/pre-commit/utils.rb
pre-commit-0.1.18 lib/pre-commit/utils.rb
pre-commit-0.1.17 lib/pre-commit/utils.rb
pre-commit-0.1.16 lib/pre-commit/utils.rb
pre-commit-0.1.15 lib/pre-commit/utils.rb
pre-commit-0.1.14 lib/pre-commit/utils.rb
pre-commit-0.1.13 lib/pre-commit/utils.rb
pre-commit-0.1.12 lib/pre-commit/utils.rb
pre-commit-0.1.11 lib/pre-commit/utils.rb
pre-commit-0.1.10 lib/pre-commit/utils.rb
pre-commit-0.1.9 lib/pre-commit/utils.rb
pre-commit-0.1.8 lib/pre-commit/utils.rb
pre-commit-0.1.7 lib/pre-commit/utils.rb
pre-commit-0.1.6 lib/pre-commit/utils.rb
pre-commit-0.1.5 lib/pre-commit/utils.rb