overcommit 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4562478a934a5f5508a128e402c8c9f427b753ef
4
- data.tar.gz: bc858f83d829676f7850cb6a5cc3b27f2abcecb4
3
+ metadata.gz: 58ead1f5474b347ce42bdbc99e97631448bf2015
4
+ data.tar.gz: e8b9c8a05a8dfc527a03bea6e73aa065d336ff2f
5
5
  SHA512:
6
- metadata.gz: d8079c98abe3278a5442e875f409c42f88075413500576ce7b086c4b0e568557bd01b9f8aef2313773135d8402f0f31880edf44407ebfa650aacaf9398300a83
7
- data.tar.gz: 3dea86ab44728d7708a7c93845c89911e102ae5da853253eee33ce886fc823ed784e996e256acf392983696c7ecff54fff885c32e637cae5ff161419290c0bc6
6
+ metadata.gz: bd933d5284859f892b55f5d7e266a56ab9f7c47f9a257fa8adb2439ebb558cc722eb367b544846dee46728829984573c768660980624f1ab53f5f0bda3092da3
7
+ data.tar.gz: 0b8ce5598eb55c8112b5af8afaa64316886c9d3c3ec853a58f23d84048388d52f0c8e1765ce1c339bce8235e4993047f174e16eaf3299e3601a6396576e379d0
@@ -1,3 +1,5 @@
1
+ require 'pathname'
2
+
1
3
  module Overcommit::GitHook
2
4
  class RubyStyle < HookSpecificCheck
3
5
  include HookRegistry
@@ -9,10 +11,9 @@ module Overcommit::GitHook
9
11
  end
10
12
 
11
13
  paths_to_staged_files = Hash[staged.map { |s| [s.path, s] }]
12
- staged_files = paths_to_staged_files.keys
13
14
 
14
- output = `rubocop --format=emacs #{staged_files.join(' ')} 2>&1`
15
- return :good if $?.success?
15
+ success, output = run_rubocop
16
+ return :good if success
16
17
 
17
18
  # Keep lines from the output for files that we actually modified
18
19
  error_lines, warning_lines = output.lines.partition do |output_line|
@@ -30,5 +31,38 @@ module Overcommit::GitHook
30
31
  return :warn, "Modified files have style lints (on lines you didn't modify)\n" <<
31
32
  warning_lines.join
32
33
  end
34
+
35
+ private
36
+
37
+ def run_rubocop
38
+ success, output = true, ''
39
+ rubocop_config_mapping.each do |config, files|
40
+ config = config ? "-c #{config}" : ''
41
+ output += `rubocop #{config} --format=emacs #{files.join(' ')} 2>&1`
42
+ success = success && $?.success?
43
+ end
44
+ [success, output]
45
+ end
46
+
47
+ def rubocop_config_mapping
48
+ staged.inject({}) do |mapping, file|
49
+ config = rubocop_yml_for(file)
50
+ mapping[config] ||= []
51
+ mapping[config] << file.path
52
+ mapping
53
+ end
54
+ end
55
+
56
+ def rubocop_yml_for(staged_file)
57
+ config_file = nil
58
+ Pathname.new(staged_file.original_path).ascend do |path|
59
+ rubo_file = path + '.rubocop.yml'
60
+ if rubo_file.file?
61
+ config_file = rubo_file
62
+ break
63
+ end
64
+ end
65
+ config_file
66
+ end
33
67
  end
34
68
  end
@@ -1,3 +1,3 @@
1
1
  module Overcommit
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Causes Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-10 00:00:00.000000000 Z
11
+ date: 2013-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 2.13.0
20
20
  type: :development
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: 2.13.0
27
27
  description: Overcommit is a utility to install and extend Git hooks
28
28
  email: eng@causes.com
29
29
  executables:
@@ -31,56 +31,56 @@ executables:
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - lib/overcommit/git_hook.rb
35
- - lib/overcommit/errors.rb
34
+ - lib/overcommit.rb
36
35
  - lib/overcommit/version.rb
37
- - lib/overcommit/hook_specific_check.rb
38
- - lib/overcommit/staged_file.rb
39
36
  - lib/overcommit/utils.rb
40
- - lib/overcommit/plugins/commit_msg/hard_tabs.rb
41
37
  - lib/overcommit/plugins/commit_msg/trailing_period.rb
42
- - lib/overcommit/plugins/commit_msg/text_width.rb
38
+ - lib/overcommit/plugins/commit_msg/change_id.rb
43
39
  - lib/overcommit/plugins/commit_msg/release_note.rb
44
40
  - lib/overcommit/plugins/commit_msg/single_line_subject.rb
45
- - lib/overcommit/plugins/commit_msg/change_id.rb
46
41
  - lib/overcommit/plugins/commit_msg/russian_novel.rb
42
+ - lib/overcommit/plugins/commit_msg/hard_tabs.rb
43
+ - lib/overcommit/plugins/commit_msg/text_width.rb
44
+ - lib/overcommit/plugins/pre_commit/js_console_log.rb
45
+ - lib/overcommit/plugins/pre_commit/haml_style.rb
47
46
  - lib/overcommit/plugins/pre_commit/ruby_syntax.rb
48
- - lib/overcommit/plugins/pre_commit/restricted_paths.rb
49
- - lib/overcommit/plugins/pre_commit/scss_lint.rb
50
- - lib/overcommit/plugins/pre_commit/css_linter.rb
51
47
  - lib/overcommit/plugins/pre_commit/js_syntax.rb
52
- - lib/overcommit/plugins/pre_commit/python_flake8.rb
48
+ - lib/overcommit/plugins/pre_commit/yaml_syntax.rb
49
+ - lib/overcommit/plugins/pre_commit/haml_syntax.rb
53
50
  - lib/overcommit/plugins/pre_commit/causes_email.rb
51
+ - lib/overcommit/plugins/pre_commit/author_name.rb
54
52
  - lib/overcommit/plugins/pre_commit/whitespace.rb
55
- - lib/overcommit/plugins/pre_commit/yaml_syntax.rb
53
+ - lib/overcommit/plugins/pre_commit/python_flake8.rb
56
54
  - lib/overcommit/plugins/pre_commit/coffee_lint.rb
57
55
  - lib/overcommit/plugins/pre_commit/test_history.rb
58
- - lib/overcommit/plugins/pre_commit/author_name.rb
59
- - lib/overcommit/plugins/pre_commit/haml_style.rb
60
- - lib/overcommit/plugins/pre_commit/js_console_log.rb
61
- - lib/overcommit/plugins/pre_commit/haml_syntax.rb
56
+ - lib/overcommit/plugins/pre_commit/restricted_paths.rb
62
57
  - lib/overcommit/plugins/pre_commit/ruby_style.rb
58
+ - lib/overcommit/plugins/pre_commit/scss_lint.rb
59
+ - lib/overcommit/plugins/pre_commit/css_linter.rb
60
+ - lib/overcommit/staged_file.rb
61
+ - lib/overcommit/reporter.rb
62
+ - lib/overcommit/hook_specific_check.rb
63
+ - lib/overcommit/installer.rb
64
+ - lib/overcommit/errors.rb
65
+ - lib/overcommit/git_hook.rb
66
+ - lib/overcommit/configuration.rb
63
67
  - lib/overcommit/hooks/pre_commit.rb
64
68
  - lib/overcommit/hooks/commit_msg.rb
65
- - lib/overcommit/configuration.rb
66
- - lib/overcommit/cli.rb
67
- - lib/overcommit/reporter.rb
68
69
  - lib/overcommit/logger.rb
69
- - lib/overcommit/installer.rb
70
- - lib/overcommit.rb
70
+ - lib/overcommit/cli.rb
71
71
  - bin/run-hook
72
+ - bin/scripts/index-tags
73
+ - bin/scripts/gerrit-change-id
74
+ - bin/scripts/jshint.js
75
+ - bin/scripts/csslint-rhino.js
76
+ - bin/scripts/check-gemfile
77
+ - bin/scripts/jshint_runner.js
72
78
  - bin/overcommit
73
- - bin/hooks/prepare-commit-msg
74
- - bin/hooks/post-checkout
75
79
  - bin/hooks/commit-msg
80
+ - bin/hooks/post-checkout
76
81
  - bin/hooks/post-merge
77
82
  - bin/hooks/pre-commit
78
- - bin/scripts/jshint.js
79
- - bin/scripts/jshint_runner.js
80
- - bin/scripts/check-gemfile
81
- - bin/scripts/index-tags
82
- - bin/scripts/csslint-rhino.js
83
- - bin/scripts/gerrit-change-id
83
+ - bin/hooks/prepare-commit-msg
84
84
  - config/templates.yml
85
85
  homepage: http://github.com/causes/overcommit
86
86
  licenses:
@@ -107,3 +107,4 @@ signing_key:
107
107
  specification_version: 4
108
108
  summary: Opinionated Git hook manager
109
109
  test_files: []
110
+ has_rdoc: