pre-commit 0.23.0 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 56459f95e495f7c552ffae3ce9a01df82fae3610
4
- data.tar.gz: 7e7ecd073b7c05d92ade69067c3e90a9f5594b47
3
+ metadata.gz: b7ea99f3d301a99ec233fe182ef6c28e38584ca4
4
+ data.tar.gz: b3bacc10c1f8c848a52491ec0f7d4816804cf1b7
5
5
  SHA512:
6
- metadata.gz: 549a9b3f4a4d44d4c938048a2b9360c968c7867a636649d56d231be51c045548599fd570795c4f5170983767bd07a4908111425072ed341c6868320c5e679373
7
- data.tar.gz: 91162e4a907af1b2b2a8d9786faf0e6092dfaa2a0bedcc533cffa2ff3ef6f69339e2beee64bdd28b7b87fe3f6f8a9fe32df498d71c8b86af14cf1c287bf46473
6
+ metadata.gz: 4ca0eaaf5dc427420f1ced3a4c765034b182443f6ec941aef2b82e0fd550dde887f753ab2f71206adb504c239023610e17ac0fa4067c6ea1bc35c3ae4ff68e40
7
+ data.tar.gz: f0a2a71ef8721284d77ccf35be3c7a8221f284397ad516e3dc384aa8861aba216793b1fca4c469c4b9ddfd39ebd755bf530551c5048f4cc1cfefa620ea059bd1
@@ -5,6 +5,12 @@ module PreCommit
5
5
  module Checks
6
6
  class Rubocop < Plugin
7
7
 
8
+ WHITELIST = [
9
+ ".gemspec", ".jbuilder", ".opal", ".podspec", ".rake", ".rb",
10
+ "Berksfile", "Capfile", "Cheffile", "Gemfile", "Guardfile", "Podfile",
11
+ "Rakefile", "Thorfile", "Vagabondfile", "Vagrantfile"
12
+ ]
13
+
8
14
  def self.aliases
9
15
  [ :rubocop_all, :rubocop_new ]
10
16
  end
@@ -18,24 +24,7 @@ module PreCommit
18
24
  rescue LoadError => e
19
25
  $stderr.puts "Could not find rubocop: #{e}"
20
26
  else
21
- allowed_files_regex = /\.gemspec\Z|
22
- \.podspec\Z|
23
- \.jbuilder\Z|
24
- \.rake\Z|
25
- \.opal\Z|
26
- \.rb\Z|
27
- Gemfile\Z|
28
- Rakefile\Z|
29
- Capfile\Z|
30
- Guardfile\Z|
31
- Podfile\Z|
32
- Thorfile\Z|
33
- Vagrantfile\Z|
34
- Berksfile\Z|
35
- Cheffile\Z|
36
- Vagabondfile\Z
37
- /x
38
- staged_files = staged_files.grep(allowed_files_regex)
27
+ staged_files = filter_staged_files(staged_files)
39
28
  return if staged_files.empty?
40
29
 
41
30
  args = config_file_flag + user_supplied_flags + ["--force-exclusion"] + staged_files
@@ -44,6 +33,11 @@ module PreCommit
44
33
  captured unless success
45
34
  end
46
35
 
36
+ def filter_staged_files(staged_files)
37
+ expression = Regexp.new(WHITELIST.map { |i| i + "\\Z" }.join("|"))
38
+ staged_files.grep(expression)
39
+ end
40
+
47
41
  def capture
48
42
  $stdout, stdout = StringIO.new, $stdout
49
43
  $stderr, stderr = StringIO.new, $stderr
@@ -23,6 +23,8 @@ module PreCommit
23
23
  end
24
24
 
25
25
  def call(staged_files)
26
+ return if staged_files.empty?
27
+
26
28
  errors = `git diff-index --check --cached HEAD -- #{files_string(staged_files)} 2>&1`
27
29
  return if $?.success?
28
30
 
@@ -9,6 +9,11 @@
9
9
  # pre-commit install --manual
10
10
  #
11
11
 
12
+ # This is a work-around to get GitHub for Mac to be able to run `node` commands
13
+ # https://stackoverflow.com/questions/12881975/git-pre-commit-hook-failing-in-github-for-mac-works-on-command-line
14
+ PATH=$PATH:/usr/local/bin:/usr/local/sbin
15
+
16
+
12
17
  cmd=`git config pre-commit.ruby 2>/dev/null`
13
18
  if test -n "${cmd}"
14
19
  then true
@@ -9,6 +9,11 @@
9
9
  # pre-commit install --manual
10
10
  #
11
11
 
12
+ # This is a work-around to get GitHub for Mac to be able to run `node` commands
13
+ # https://stackoverflow.com/questions/12881975/git-pre-commit-hook-failing-in-github-for-mac-works-on-command-line
14
+ PATH=$PATH:/usr/local/bin:/usr/local/sbin
15
+
16
+
12
17
  cmd=`git config pre-commit.ruby 2>/dev/null`
13
18
  if test -n "${cmd}"
14
19
  then true
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.23.0
4
+ version: 0.24.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: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pluginator
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
201
201
  version: '0'
202
202
  requirements: []
203
203
  rubyforge_project:
204
- rubygems_version: 2.2.2
204
+ rubygems_version: 2.2.3
205
205
  signing_key:
206
206
  specification_version: 3
207
207
  summary: A slightly better git pre-commit hook