pre-commit 0.12.0 → 0.13.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 +39 -16
- data/bin/pre-commit +1 -12
- data/lib/plugins/pluginator/extensions/find_check.rb +26 -0
- data/lib/plugins/pre_commit/checks/before_all.rb +23 -7
- data/lib/plugins/pre_commit/checks/ci.rb +10 -3
- data/lib/plugins/pre_commit/checks/closure.rb +12 -4
- data/lib/plugins/pre_commit/checks/coffeelint.rb +9 -4
- data/lib/plugins/pre_commit/checks/common.rb +17 -0
- data/lib/plugins/pre_commit/checks/console_log.rb +23 -7
- data/lib/plugins/pre_commit/checks/csslint.rb +32 -0
- data/lib/plugins/pre_commit/checks/debugger.rb +14 -10
- data/lib/plugins/pre_commit/checks/gemfile_path.rb +18 -7
- data/lib/plugins/pre_commit/checks/jshint.rb +10 -4
- data/lib/plugins/pre_commit/checks/jslint.rb +11 -5
- data/lib/plugins/pre_commit/checks/local.rb +10 -2
- data/lib/plugins/pre_commit/checks/merge_conflict.rb +15 -6
- data/lib/plugins/pre_commit/checks/migration.rb +32 -26
- data/lib/plugins/pre_commit/checks/nb_space.rb +10 -2
- data/lib/plugins/pre_commit/checks/php.rb +10 -4
- data/lib/plugins/pre_commit/checks/pry.rb +15 -6
- data/lib/plugins/pre_commit/checks/rails.rb +17 -0
- data/lib/plugins/pre_commit/checks/rspec_focus.rb +19 -7
- data/lib/plugins/pre_commit/checks/rubocop.rb +20 -8
- data/lib/plugins/pre_commit/checks/ruby.rb +17 -0
- data/lib/plugins/pre_commit/checks/ruby_symbol_hashrockets.rb +17 -8
- data/lib/plugins/pre_commit/checks/tabs.rb +15 -8
- data/lib/plugins/pre_commit/checks/whitespace.rb +28 -5
- data/lib/plugins/pre_commit/configuration/providers/README.md +10 -0
- data/lib/plugins/pre_commit/configuration/providers/default.rb +34 -0
- data/lib/plugins/pre_commit/configuration/providers/git.rb +26 -0
- data/lib/plugins/pre_commit/configuration/providers/git_old.rb +28 -0
- data/lib/plugins/pre_commit/configuration/providers/yaml.rb +67 -0
- data/lib/pre-commit.rb +28 -1
- data/lib/pre-commit/checks.rb +1 -98
- data/lib/pre-commit/checks/grep.rb +57 -0
- data/lib/{plugins/pre_commit → pre-commit}/checks/js.rb +15 -7
- data/lib/pre-commit/checks/plugin.rb +13 -0
- data/lib/pre-commit/cli.rb +46 -19
- data/lib/pre-commit/configuration.rb +54 -0
- data/lib/pre-commit/configuration/providers.rb +53 -0
- data/lib/pre-commit/installer.rb +54 -0
- data/lib/pre-commit/list_evaluator.rb +85 -0
- data/lib/pre-commit/plugins_list.rb +87 -0
- data/lib/pre-commit/runner.rb +54 -9
- data/lib/pre-commit/support/csslint/csslint.js +9259 -0
- data/lib/pre-commit/utils/git_conversions.rb +56 -0
- data/lib/pre-commit/utils/staged_files.rb +21 -0
- metadata +47 -30
- data/lib/pre-commit/support/templates/automatic_hook +0 -35
- data/lib/pre-commit/support/templates/default_hook +0 -35
- data/lib/pre-commit/support/templates/manual_hook +0 -14
- data/lib/pre-commit/utils.rb +0 -27
@@ -0,0 +1,56 @@
|
|
1
|
+
module PreCommit
|
2
|
+
module Utils
|
3
|
+
module GitConversions
|
4
|
+
|
5
|
+
# git_to_ruby related
|
6
|
+
|
7
|
+
def git_to_ruby(value)
|
8
|
+
value = value.chomp.strip if String === value
|
9
|
+
case value
|
10
|
+
when /\A\[(.*)\]\Z/
|
11
|
+
str2arr($1)
|
12
|
+
when ''
|
13
|
+
nil
|
14
|
+
when String
|
15
|
+
str_symbolize(value)
|
16
|
+
else
|
17
|
+
value
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def str2arr(string)
|
22
|
+
string.split(/, ?/).map{|string| str_symbolize(string.chomp.strip) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def str_symbolize(string)
|
26
|
+
if string =~ /\A:(.*)\Z/
|
27
|
+
then $1.to_sym
|
28
|
+
else string
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# ruby_to_git related
|
33
|
+
|
34
|
+
def ruby_to_git(value)
|
35
|
+
case value
|
36
|
+
when Array
|
37
|
+
arr2str(value)
|
38
|
+
else
|
39
|
+
sym_symbolize(value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def arr2str(value)
|
44
|
+
"[#{value.map{|v| sym_symbolize(v) }.join(", ")}]"
|
45
|
+
end
|
46
|
+
|
47
|
+
def sym_symbolize(value)
|
48
|
+
if Symbol === value
|
49
|
+
then ":#{value}"
|
50
|
+
else value.to_s
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module PreCommit
|
2
|
+
module Utils
|
3
|
+
module StagedFiles
|
4
|
+
|
5
|
+
def staged_files
|
6
|
+
@staged_files ||= begin
|
7
|
+
files = `git diff --cached --name-only --diff-filter=ACM`.split
|
8
|
+
files.reject { |f| size = File.size(f); size > 1_000_000 || (size > 20 && binary?(f)) }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
# from https://github.com/djberg96/ptools/blob/master/lib/ptools.rb#L90
|
14
|
+
def binary?(file)
|
15
|
+
s = (File.read(file, File.stat(file).blksize) || "").split(//)
|
16
|
+
((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pre-commit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.13.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:
|
11
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pluginator
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '1.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: guard-minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '2.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
68
|
+
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '4.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '4.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest-reporters
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: A git pre-commit hook written in ruby with a few more tricks up its sleeve
|
@@ -102,14 +102,16 @@ extensions: []
|
|
102
102
|
extra_rdoc_files:
|
103
103
|
- README.md
|
104
104
|
files:
|
105
|
+
- lib/plugins/pluginator/extensions/find_check.rb
|
105
106
|
- lib/plugins/pre_commit/checks/before_all.rb
|
106
107
|
- lib/plugins/pre_commit/checks/ci.rb
|
107
108
|
- lib/plugins/pre_commit/checks/closure.rb
|
108
109
|
- lib/plugins/pre_commit/checks/coffeelint.rb
|
110
|
+
- lib/plugins/pre_commit/checks/common.rb
|
109
111
|
- lib/plugins/pre_commit/checks/console_log.rb
|
112
|
+
- lib/plugins/pre_commit/checks/csslint.rb
|
110
113
|
- lib/plugins/pre_commit/checks/debugger.rb
|
111
114
|
- lib/plugins/pre_commit/checks/gemfile_path.rb
|
112
|
-
- lib/plugins/pre_commit/checks/js.rb
|
113
115
|
- lib/plugins/pre_commit/checks/jshint.rb
|
114
116
|
- lib/plugins/pre_commit/checks/jslint.rb
|
115
117
|
- lib/plugins/pre_commit/checks/local.rb
|
@@ -118,21 +120,35 @@ files:
|
|
118
120
|
- lib/plugins/pre_commit/checks/nb_space.rb
|
119
121
|
- lib/plugins/pre_commit/checks/php.rb
|
120
122
|
- lib/plugins/pre_commit/checks/pry.rb
|
123
|
+
- lib/plugins/pre_commit/checks/rails.rb
|
121
124
|
- lib/plugins/pre_commit/checks/rspec_focus.rb
|
122
125
|
- lib/plugins/pre_commit/checks/rubocop.rb
|
126
|
+
- lib/plugins/pre_commit/checks/ruby.rb
|
123
127
|
- lib/plugins/pre_commit/checks/ruby_symbol_hashrockets.rb
|
124
128
|
- lib/plugins/pre_commit/checks/tabs.rb
|
125
129
|
- lib/plugins/pre_commit/checks/whitespace.rb
|
130
|
+
- lib/plugins/pre_commit/configuration/providers/default.rb
|
131
|
+
- lib/plugins/pre_commit/configuration/providers/git.rb
|
132
|
+
- lib/plugins/pre_commit/configuration/providers/git_old.rb
|
133
|
+
- lib/plugins/pre_commit/configuration/providers/README.md
|
134
|
+
- lib/plugins/pre_commit/configuration/providers/yaml.rb
|
135
|
+
- lib/pre-commit/checks/grep.rb
|
136
|
+
- lib/pre-commit/checks/js.rb
|
137
|
+
- lib/pre-commit/checks/plugin.rb
|
126
138
|
- lib/pre-commit/checks.rb
|
127
139
|
- lib/pre-commit/cli.rb
|
140
|
+
- lib/pre-commit/configuration/providers.rb
|
141
|
+
- lib/pre-commit/configuration.rb
|
142
|
+
- lib/pre-commit/installer.rb
|
143
|
+
- lib/pre-commit/list_evaluator.rb
|
144
|
+
- lib/pre-commit/plugins_list.rb
|
128
145
|
- lib/pre-commit/runner.rb
|
129
146
|
- lib/pre-commit/support/closure/compiler.jar
|
147
|
+
- lib/pre-commit/support/csslint/csslint.js
|
130
148
|
- lib/pre-commit/support/jshint/jshint.js
|
131
149
|
- lib/pre-commit/support/jslint/lint.js
|
132
|
-
- lib/pre-commit/
|
133
|
-
- lib/pre-commit/
|
134
|
-
- lib/pre-commit/support/templates/manual_hook
|
135
|
-
- lib/pre-commit/utils.rb
|
150
|
+
- lib/pre-commit/utils/git_conversions.rb
|
151
|
+
- lib/pre-commit/utils/staged_files.rb
|
136
152
|
- lib/pre-commit.rb
|
137
153
|
- README.md
|
138
154
|
- bin/pre-commit
|
@@ -158,8 +174,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
174
|
version: '0'
|
159
175
|
requirements: []
|
160
176
|
rubyforge_project:
|
161
|
-
rubygems_version: 2.
|
177
|
+
rubygems_version: 2.0.2
|
162
178
|
signing_key:
|
163
179
|
specification_version: 3
|
164
180
|
summary: A slightly better git pre-commit hook
|
165
181
|
test_files: []
|
182
|
+
has_rdoc:
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env sh
|
2
|
-
|
3
|
-
# This hook has a focus on portability.
|
4
|
-
# This hook will attempt to setup your environment before running checks.
|
5
|
-
#
|
6
|
-
# If you would like `pre-commit` to get out of your way and you are comfortable
|
7
|
-
# setting up your own environment, you can install the manual hook using:
|
8
|
-
#
|
9
|
-
# pre-commit install --manual
|
10
|
-
#
|
11
|
-
|
12
|
-
cmd=`git config pre-commit.ruby 2>/dev/null`
|
13
|
-
if test -n "${cmd}"
|
14
|
-
then true
|
15
|
-
elif which rvm > /dev/null
|
16
|
-
then cmd="rvm default do ruby"
|
17
|
-
elif which rbenv > /dev/null
|
18
|
-
then cmd="rbenv exec ruby"
|
19
|
-
else cmd="ruby"
|
20
|
-
fi
|
21
|
-
|
22
|
-
export rvm_silence_path_mismatch_check_flag=1
|
23
|
-
|
24
|
-
${cmd} -rrubygems -e '
|
25
|
-
begin
|
26
|
-
require "pre-commit"
|
27
|
-
true
|
28
|
-
rescue LoadError => e
|
29
|
-
$stderr.puts <<-MESSAGE
|
30
|
-
pre-commit: WARNING: Skipping checks because: #{e}
|
31
|
-
pre-commit: Did you set your Ruby version?
|
32
|
-
MESSAGE
|
33
|
-
false
|
34
|
-
end and PreCommit.run
|
35
|
-
'
|
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env sh
|
2
|
-
|
3
|
-
# This hook has a focus on portability.
|
4
|
-
# This hook will attempt to setup your environment before running checks.
|
5
|
-
#
|
6
|
-
# If you would like `pre-commit` to get out of your way and you are comfortable
|
7
|
-
# setting up your own environment, you can install the manual hook using:
|
8
|
-
#
|
9
|
-
# pre-commit install --manual
|
10
|
-
#
|
11
|
-
|
12
|
-
cmd=`git config pre-commit.ruby 2>/dev/null`
|
13
|
-
if test -n "${cmd}"
|
14
|
-
then true
|
15
|
-
elif which rvm > /dev/null
|
16
|
-
then cmd="rvm default do ruby"
|
17
|
-
elif which rbenv > /dev/null
|
18
|
-
then cmd="rbenv exec ruby"
|
19
|
-
else cmd="ruby"
|
20
|
-
fi
|
21
|
-
|
22
|
-
export rvm_silence_path_mismatch_check_flag=1
|
23
|
-
|
24
|
-
${cmd} -rrubygems -e '
|
25
|
-
begin
|
26
|
-
require "pre-commit"
|
27
|
-
true
|
28
|
-
rescue LoadError => e
|
29
|
-
$stderr.puts <<-MESSAGE
|
30
|
-
pre-commit: WARNING: Skipping checks because: #{e}
|
31
|
-
pre-commit: Did you set your Ruby version?
|
32
|
-
MESSAGE
|
33
|
-
false
|
34
|
-
end and PreCommit.run
|
35
|
-
'
|
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# This hook has a focus on simplicity.
|
4
|
-
# This hook puts the burden on you to set up your environment properly.
|
5
|
-
#
|
6
|
-
# If you would like `pre-commit` to attempt to setup your environment for you
|
7
|
-
# before the checks run, you can install the automatic environment hook using:
|
8
|
-
#
|
9
|
-
# pre-commit install --automatic
|
10
|
-
#
|
11
|
-
|
12
|
-
require 'pre-commit'
|
13
|
-
|
14
|
-
PreCommit.run
|
data/lib/pre-commit/utils.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
module PreCommit
|
2
|
-
class Utils
|
3
|
-
|
4
|
-
def self.staged_files
|
5
|
-
@staged_files ||= begin
|
6
|
-
files = `git diff --cached --name-only --diff-filter=ACM`.split
|
7
|
-
files.reject { |f| size = File.size(f); size > 1_000_000 || (size > 20 && binary?(f)) }
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
# from https://github.com/djberg96/ptools/blob/master/lib/ptools.rb#L90
|
12
|
-
def self.binary?(file)
|
13
|
-
s = (File.read(file, File.stat(file).blksize) || "").split(//)
|
14
|
-
((s.size - s.grep(" ".."~").size) / s.size.to_f) > 0.30
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.grep
|
18
|
-
grep_version = `grep --version | head -n 1 | sed -e 's/^[^0-9.]*\([0-9.]*\)$/\1/'`
|
19
|
-
if grep_version =~ /FreeBSD/
|
20
|
-
"grep -EnIH"
|
21
|
-
else
|
22
|
-
"grep -PnIH"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|