pre-commit 0.18.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/plugins/pre_commit/checks/rspec_focus.rb +1 -1
- data/lib/pre-commit/checks/grep.rb +2 -1
- data/lib/pre-commit/utils/staged_files.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47b088bf66a3dce520c9a2e2c7b2573a5da3dc4d
|
4
|
+
data.tar.gz: b2712aafb68d68ae5226e1a79800e705b8ec1947
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed5b63347c42c6cd96782865d9513f2f63a3bb7ec5e924c27ef403667981b3e5d51ef6d557e719a7542ef0e36073de715aeeee83ea172105565e9df2755280ed
|
7
|
+
data.tar.gz: c90634c849ddc7fd8e294fa408b3474c0c23e7f85a35bb6492e14311c289dac127ecca75b1b07bcc8ecfece8feefc61bf16d250be52298de32fd6ad53fe9b749
|
data/README.md
CHANGED
@@ -94,6 +94,7 @@ This functionality was added in version `0.17.0`
|
|
94
94
|
```bash
|
95
95
|
pre-commit run # run on the files added to index not yet commited
|
96
96
|
pre-commit run all # run on all files in current directory
|
97
|
+
pre-commit run git # run on all git-tracked files, respect gitignore (added in 0.19.0)
|
97
98
|
pre-commit run <file-list> # run on the list of files, patterns not supported
|
98
99
|
```
|
99
100
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'pre-commit/checks/plugin'
|
2
|
+
require 'shellwords'
|
2
3
|
|
3
4
|
module PreCommit
|
4
5
|
module Checks
|
@@ -30,7 +31,7 @@ module PreCommit
|
|
30
31
|
# general code:
|
31
32
|
|
32
33
|
def call(staged_files)
|
33
|
-
staged_files = files_filter(staged_files)
|
34
|
+
staged_files = files_filter(staged_files).map(&:shellescape)
|
34
35
|
return if staged_files.empty?
|
35
36
|
errors = `#{grep} #{pattern} #{staged_files.join(" ")}#{extra_grep}`
|
36
37
|
return unless $?.success?
|
@@ -5,6 +5,7 @@ module PreCommit
|
|
5
5
|
def set_staged_files(*args)
|
6
6
|
case args[0].to_s
|
7
7
|
when "all" then staged_files_all
|
8
|
+
when "git" then staged_files_git_all
|
8
9
|
when "" then staged_files
|
9
10
|
else self.staged_files=args
|
10
11
|
end
|
@@ -22,6 +23,10 @@ module PreCommit
|
|
22
23
|
@staged_files = filter_files(staged_from_dir)
|
23
24
|
end
|
24
25
|
|
26
|
+
def staged_files_git_all
|
27
|
+
@staged_files = filter_files(staged_from_git_all)
|
28
|
+
end
|
29
|
+
|
25
30
|
private
|
26
31
|
# from https://github.com/djberg96/ptools/blob/master/lib/ptools.rb#L90
|
27
32
|
def binary?(file)
|
@@ -43,6 +48,10 @@ module PreCommit
|
|
43
48
|
`git diff --cached --name-only --diff-filter=ACM`.split(/\n/)
|
44
49
|
end
|
45
50
|
|
51
|
+
def staged_from_git_all
|
52
|
+
`git ls-files`.split(/\n/)
|
53
|
+
end
|
54
|
+
|
46
55
|
def staged_from_dir
|
47
56
|
Dir["**/*"]
|
48
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pre-commit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shajith Chacko, Josh Lubaway
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pluginator
|