pre-commit 0.13.0 → 0.14.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 +3 -2
- data/lib/plugins/pre_commit/checks/go.rb +29 -0
- data/templates/hooks/automatic +35 -0
- data/templates/hooks/default +35 -0
- data/templates/hooks/manual +14 -0
- metadata +28 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f0a961a8ae09c2f2a45bf2994286f6663ecea2b
|
4
|
+
data.tar.gz: 594524190b267458b7d22938c0abda3844906eb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d29ffe1b7800870e4c11061846ab9737bc0ca1f8bb7929a00ccc032fec7ad78e7e1e8874779526c70d85b2b5a4ac02d2fffbad94ed1db19a82c9de3578cf4cf
|
7
|
+
data.tar.gz: 9cfba58f5e5789aa12ffccb703ac3fc22abcc65282b9f4f4ed8bc2ca9c965f1af0955dd74c76f5033fb20327d72b879e80d1ca2a85c8624abeb22a8fe47b533f
|
data/README.md
CHANGED
@@ -42,6 +42,7 @@ These are the available checks:
|
|
42
42
|
* rubocop (Check ruby code style using the rubocop gem. Rubocop must be installed)
|
43
43
|
* before_all (Check your RSpec tests for the use of `before(:all)`)
|
44
44
|
* coffeelint (Check your coffeescript files using the [coffeelint gem.](https://github.com/clutchski/coffeelint))
|
45
|
+
* go (Runs go fmt on a go source file and fail if formatting is incorrect, then runs go build and fails if can't compile)
|
45
46
|
|
46
47
|
## Default checks
|
47
48
|
|
@@ -49,7 +50,7 @@ Use `pre-commit list` to see the list of default and enabled checks and warnings
|
|
49
50
|
|
50
51
|
## Enabling / Disabling Checks / Warnings
|
51
52
|
|
52
|
-
###
|
53
|
+
### Git configuration
|
53
54
|
|
54
55
|
git config pre-commit.checks "whitespace, jshint, debugger"
|
55
56
|
|
@@ -57,7 +58,7 @@ To disable, simply leave one off the list
|
|
57
58
|
|
58
59
|
git config pre-commit.checks "whitespace, jshint"
|
59
60
|
|
60
|
-
###
|
61
|
+
### CLI configuration
|
61
62
|
|
62
63
|
```ssh
|
63
64
|
pre-commit <enable|disbale> <git|yaml> <checks|warnings> check1 [check2...]
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'pre-commit/checks/plugin'
|
2
|
+
|
3
|
+
module PreCommit
|
4
|
+
module Checks
|
5
|
+
class Go < Plugin
|
6
|
+
|
7
|
+
def call(staged_files)
|
8
|
+
staged_files = staged_files.grep(/\.go$/)
|
9
|
+
return if staged_files.empty?
|
10
|
+
|
11
|
+
errors = staged_files.map { |file| run_check(file) }.compact
|
12
|
+
return if errors.empty?
|
13
|
+
|
14
|
+
errors.join("\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
def run_check(file)
|
18
|
+
cmd = "gofmt -l #{file} 2>&1"
|
19
|
+
result = %x[ #{cmd} ]
|
20
|
+
cmd = "go build -o /dev/null #{file} 2>&1"
|
21
|
+
result << %x[ #{cmd} ]
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.description
|
25
|
+
"Detects bad Go formatting and compiler errors"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
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
|
+
'
|
@@ -0,0 +1,35 @@
|
|
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
|
+
'
|
@@ -0,0 +1,14 @@
|
|
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
|
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.14.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-02-
|
11
|
+
date: 2014-02-18 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
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
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
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
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
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
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
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
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
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
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,6 +102,8 @@ extensions: []
|
|
102
102
|
extra_rdoc_files:
|
103
103
|
- README.md
|
104
104
|
files:
|
105
|
+
- README.md
|
106
|
+
- bin/pre-commit
|
105
107
|
- lib/plugins/pluginator/extensions/find_check.rb
|
106
108
|
- lib/plugins/pre_commit/checks/before_all.rb
|
107
109
|
- lib/plugins/pre_commit/checks/ci.rb
|
@@ -112,6 +114,7 @@ files:
|
|
112
114
|
- lib/plugins/pre_commit/checks/csslint.rb
|
113
115
|
- lib/plugins/pre_commit/checks/debugger.rb
|
114
116
|
- lib/plugins/pre_commit/checks/gemfile_path.rb
|
117
|
+
- lib/plugins/pre_commit/checks/go.rb
|
115
118
|
- lib/plugins/pre_commit/checks/jshint.rb
|
116
119
|
- lib/plugins/pre_commit/checks/jslint.rb
|
117
120
|
- lib/plugins/pre_commit/checks/local.rb
|
@@ -127,18 +130,19 @@ files:
|
|
127
130
|
- lib/plugins/pre_commit/checks/ruby_symbol_hashrockets.rb
|
128
131
|
- lib/plugins/pre_commit/checks/tabs.rb
|
129
132
|
- lib/plugins/pre_commit/checks/whitespace.rb
|
133
|
+
- lib/plugins/pre_commit/configuration/providers/README.md
|
130
134
|
- lib/plugins/pre_commit/configuration/providers/default.rb
|
131
135
|
- lib/plugins/pre_commit/configuration/providers/git.rb
|
132
136
|
- lib/plugins/pre_commit/configuration/providers/git_old.rb
|
133
|
-
- lib/plugins/pre_commit/configuration/providers/README.md
|
134
137
|
- lib/plugins/pre_commit/configuration/providers/yaml.rb
|
138
|
+
- lib/pre-commit.rb
|
139
|
+
- lib/pre-commit/checks.rb
|
135
140
|
- lib/pre-commit/checks/grep.rb
|
136
141
|
- lib/pre-commit/checks/js.rb
|
137
142
|
- lib/pre-commit/checks/plugin.rb
|
138
|
-
- lib/pre-commit/checks.rb
|
139
143
|
- lib/pre-commit/cli.rb
|
140
|
-
- lib/pre-commit/configuration/providers.rb
|
141
144
|
- lib/pre-commit/configuration.rb
|
145
|
+
- lib/pre-commit/configuration/providers.rb
|
142
146
|
- lib/pre-commit/installer.rb
|
143
147
|
- lib/pre-commit/list_evaluator.rb
|
144
148
|
- lib/pre-commit/plugins_list.rb
|
@@ -149,34 +153,33 @@ files:
|
|
149
153
|
- lib/pre-commit/support/jslint/lint.js
|
150
154
|
- lib/pre-commit/utils/git_conversions.rb
|
151
155
|
- lib/pre-commit/utils/staged_files.rb
|
152
|
-
-
|
153
|
-
-
|
154
|
-
-
|
156
|
+
- templates/hooks/automatic
|
157
|
+
- templates/hooks/default
|
158
|
+
- templates/hooks/manual
|
155
159
|
homepage: http://github.com/jish/pre-commit
|
156
160
|
licenses:
|
157
161
|
- Apache 2.0
|
158
162
|
metadata: {}
|
159
163
|
post_install_message:
|
160
164
|
rdoc_options:
|
161
|
-
- --main
|
165
|
+
- "--main"
|
162
166
|
- README.md
|
163
167
|
require_paths:
|
164
168
|
- lib
|
165
169
|
required_ruby_version: !ruby/object:Gem::Requirement
|
166
170
|
requirements:
|
167
|
-
- -
|
171
|
+
- - ">="
|
168
172
|
- !ruby/object:Gem::Version
|
169
173
|
version: '0'
|
170
174
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
175
|
requirements:
|
172
|
-
- -
|
176
|
+
- - ">="
|
173
177
|
- !ruby/object:Gem::Version
|
174
178
|
version: '0'
|
175
179
|
requirements: []
|
176
180
|
rubyforge_project:
|
177
|
-
rubygems_version: 2.0
|
181
|
+
rubygems_version: 2.2.0
|
178
182
|
signing_key:
|
179
183
|
specification_version: 3
|
180
184
|
summary: A slightly better git pre-commit hook
|
181
185
|
test_files: []
|
182
|
-
has_rdoc:
|