overcommit 0.25.0 → 0.26.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/config/default.yml +5 -0
- data/config/starter.yml +1 -1
- data/lib/overcommit/configuration.rb +6 -2
- data/lib/overcommit/git_repo.rb +1 -1
- data/lib/overcommit/hook/base.rb +28 -27
- data/lib/overcommit/hook/commit_msg/empty_message.rb +10 -0
- data/lib/overcommit/hook/commit_msg/gerrit_change_id.rb +2 -0
- data/lib/overcommit/hook/commit_msg/spell_check.rb +3 -1
- data/lib/overcommit/hook/post_checkout/index_tags.rb +2 -0
- data/lib/overcommit/hook/post_commit/git_guilt.rb +2 -0
- data/lib/overcommit/hook/post_commit/index_tags.rb +2 -0
- data/lib/overcommit/hook/post_merge/index_tags.rb +2 -0
- data/lib/overcommit/hook/post_rewrite/index_tags.rb +2 -0
- data/lib/overcommit/hook/pre_commit/berksfile_check.rb +2 -0
- data/lib/overcommit/hook/pre_commit/brakeman.rb +2 -0
- data/lib/overcommit/hook/pre_commit/bundle_check.rb +2 -0
- data/lib/overcommit/hook/pre_commit/case_conflicts.rb +7 -2
- data/lib/overcommit/hook/pre_commit/chamber_security.rb +3 -1
- data/lib/overcommit/hook/pre_commit/coffee_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/css_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/es_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/go_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/go_vet.rb +2 -0
- data/lib/overcommit/hook/pre_commit/haml_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/html_tidy.rb +2 -0
- data/lib/overcommit/hook/pre_commit/image_optim.rb +2 -0
- data/lib/overcommit/hook/pre_commit/java_checkstyle.rb +2 -0
- data/lib/overcommit/hook/pre_commit/js_hint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/js_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/jscs.rb +2 -0
- data/lib/overcommit/hook/pre_commit/jsl.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pep257.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pep8.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pyflakes.rb +2 -0
- data/lib/overcommit/hook/pre_commit/pylint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/python_flake8.rb +2 -0
- data/lib/overcommit/hook/pre_commit/reek.rb +3 -1
- data/lib/overcommit/hook/pre_commit/rubo_cop.rb +2 -0
- data/lib/overcommit/hook/pre_commit/ruby_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/scalariform.rb +2 -0
- data/lib/overcommit/hook/pre_commit/scalastyle.rb +2 -0
- data/lib/overcommit/hook/pre_commit/scss_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/semi_standard.rb +2 -0
- data/lib/overcommit/hook/pre_commit/shell_check.rb +2 -0
- data/lib/overcommit/hook/pre_commit/slim_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/standard.rb +2 -0
- data/lib/overcommit/hook/pre_commit/travis_lint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/vint.rb +2 -0
- data/lib/overcommit/hook/pre_commit/w3c_css.rb +2 -0
- data/lib/overcommit/hook/pre_commit/w3c_html.rb +2 -0
- data/lib/overcommit/hook/pre_commit/xml_lint.rb +2 -0
- data/lib/overcommit/hook/pre_push/r_spec.rb +2 -0
- data/lib/overcommit/hook/pre_rebase/base.rb +2 -1
- data/lib/overcommit/hook/shared/index_tags.rb +2 -0
- data/lib/overcommit/hook_context/pre_commit.rb +11 -3
- data/lib/overcommit/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f071e1a8038ef082833913a8eb83e6bfb44b371
|
4
|
+
data.tar.gz: eb442b2dc4457f8173f9fff48572f575839c39e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2e2faad1aea169d67e252967d22397bf05a4511fdb5247a57f3b2d12e66fa186ea594a24819619e648d56d90b30a965e643027e320e8b4340c785f31e6ae4b9
|
7
|
+
data.tar.gz: a8b53b06f1ab3b4eb6cbf31cf77abfdf053a7af1719f2b0e1482ca5c1e4ea62082357d00a921415286f8340675e9734cad1d73d0a69fd0dd261bf6194ef43b27
|
data/config/default.yml
CHANGED
@@ -26,6 +26,11 @@ CommitMsg:
|
|
26
26
|
enabled: true
|
27
27
|
description: 'Checking subject capitalization'
|
28
28
|
|
29
|
+
EmptyMessage:
|
30
|
+
enabled: true
|
31
|
+
description: 'Checking for empty commit message'
|
32
|
+
quiet: true
|
33
|
+
|
29
34
|
GerritChangeId:
|
30
35
|
enabled: false
|
31
36
|
description: 'Ensuring Gerrit Change-Id is present'
|
data/config/starter.yml
CHANGED
@@ -162,8 +162,12 @@ module Overcommit
|
|
162
162
|
end
|
163
163
|
|
164
164
|
def hook_enabled?(hook_context_or_type, hook_name)
|
165
|
-
hook_type =
|
166
|
-
|
165
|
+
hook_type =
|
166
|
+
if hook_context_or_type.is_a?(String)
|
167
|
+
hook_context_or_type
|
168
|
+
else
|
169
|
+
hook_context_or_type.hook_class_name
|
170
|
+
end
|
167
171
|
|
168
172
|
individual_enabled = @hash[hook_type].fetch(hook_name, {})['enabled']
|
169
173
|
return individual_enabled unless individual_enabled.nil?
|
data/lib/overcommit/git_repo.rb
CHANGED
@@ -107,7 +107,7 @@ module Overcommit
|
|
107
107
|
# @return [Array<String>] list of absolute file paths
|
108
108
|
def list_files(paths = [], options = {})
|
109
109
|
ref = options[:ref] || 'HEAD'
|
110
|
-
`git ls-tree --name-only #{ref} #{paths.join(' ')}`.
|
110
|
+
`git ls-tree --name-only #{ref} "#{paths.join('" "')}"`.
|
111
111
|
split(/\n/).
|
112
112
|
map { |relative_file| File.expand_path(relative_file) }.
|
113
113
|
reject { |file| File.directory?(file) } # Exclude submodule directories
|
data/lib/overcommit/hook/base.rb
CHANGED
@@ -42,38 +42,13 @@ module Overcommit::Hook
|
|
42
42
|
if output = check_for_requirements
|
43
43
|
status = :fail
|
44
44
|
else
|
45
|
-
|
45
|
+
result = Overcommit::Utils.with_environment(@config.fetch('env', {})) { run }
|
46
|
+
status, output = process_hook_return_value(result)
|
46
47
|
end
|
47
48
|
|
48
49
|
[transform_status(status), output]
|
49
50
|
end
|
50
51
|
|
51
|
-
# Converts the hook's return value into a canonical form of a tuple
|
52
|
-
# containing status (pass/warn/fail) and output.
|
53
|
-
#
|
54
|
-
# This is intended to support various shortcuts for writing hooks so that
|
55
|
-
# hook authors don't need to work with {Overcommit::Hook::Message} objects
|
56
|
-
# for simple pass/fail hooks. It also saves you from needing to manually
|
57
|
-
# encode logic like "if there are errors, fail; if there are warnings, warn,
|
58
|
-
# otherwise pass." by simply returning an array of
|
59
|
-
# {Overcommit::Hook::Message} objects.
|
60
|
-
#
|
61
|
-
# @param hook_return_value [Symbol, Array<Symbol,String>, Array<Message>]
|
62
|
-
# @return [Array<Symbol,String>] tuple of status and output
|
63
|
-
def process_hook_return_value(hook_return_value)
|
64
|
-
if hook_return_value.is_a?(Array) &&
|
65
|
-
(hook_return_value.first.is_a?(Message) || hook_return_value.empty?)
|
66
|
-
# Process messages into a status and output
|
67
|
-
Overcommit::MessageProcessor.new(
|
68
|
-
self,
|
69
|
-
@config['problem_on_unmodified_line'],
|
70
|
-
).hook_result(hook_return_value)
|
71
|
-
else
|
72
|
-
# Otherwise return as-is
|
73
|
-
hook_return_value
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
52
|
def name
|
78
53
|
self.class.name.split('::').last
|
79
54
|
end
|
@@ -230,6 +205,32 @@ module Overcommit::Hook
|
|
230
205
|
output.join("\n")
|
231
206
|
end
|
232
207
|
|
208
|
+
# Converts the hook's return value into a canonical form of a tuple
|
209
|
+
# containing status (pass/warn/fail) and output.
|
210
|
+
#
|
211
|
+
# This is intended to support various shortcuts for writing hooks so that
|
212
|
+
# hook authors don't need to work with {Overcommit::Hook::Message} objects
|
213
|
+
# for simple pass/fail hooks. It also saves you from needing to manually
|
214
|
+
# encode logic like "if there are errors, fail; if there are warnings, warn,
|
215
|
+
# otherwise pass." by simply returning an array of
|
216
|
+
# {Overcommit::Hook::Message} objects.
|
217
|
+
#
|
218
|
+
# @param hook_return_value [Symbol, Array<Symbol,String>, Array<Message>]
|
219
|
+
# @return [Array<Symbol,String>] tuple of status and output
|
220
|
+
def process_hook_return_value(hook_return_value)
|
221
|
+
if hook_return_value.is_a?(Array) &&
|
222
|
+
(hook_return_value.first.is_a?(Message) || hook_return_value.empty?)
|
223
|
+
# Process messages into a status and output
|
224
|
+
Overcommit::MessageProcessor.new(
|
225
|
+
self,
|
226
|
+
@config['problem_on_unmodified_line'],
|
227
|
+
).hook_result(hook_return_value)
|
228
|
+
else
|
229
|
+
# Otherwise return as-is
|
230
|
+
hook_return_value
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
233
234
|
# Transforms the hook's status based on custom configuration.
|
234
235
|
#
|
235
236
|
# This allows users to change failures into warnings, or vice versa.
|
@@ -5,6 +5,8 @@ module Overcommit::Hook::CommitMsg
|
|
5
5
|
# the reality is that if you want to _ensure_ the Change-Id is included then
|
6
6
|
# you need to do it in a commit-msg hook. This is because the user could still
|
7
7
|
# edit the message after a prepare-commit-msg hook was run.
|
8
|
+
#
|
9
|
+
# @see https://code.google.com/p/gerrit/
|
8
10
|
class GerritChangeId < Base
|
9
11
|
SCRIPT_LOCATION = Overcommit::Utils.script_path('gerrit-change-id')
|
10
12
|
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require 'tempfile'
|
2
2
|
|
3
3
|
module Overcommit::Hook::CommitMsg
|
4
|
-
# Checks the commit message for potential misspellings
|
4
|
+
# Checks the commit message for potential misspellings with `hunspell`.
|
5
|
+
#
|
6
|
+
# @see http://hunspell.sourceforge.net/
|
5
7
|
class SpellCheck < Base
|
6
8
|
Misspelling = Struct.new(:word, :suggestions)
|
7
9
|
|
@@ -2,6 +2,8 @@ require 'overcommit/hook/shared/index_tags'
|
|
2
2
|
|
3
3
|
module Overcommit::Hook::PostCheckout
|
4
4
|
# Updates ctags index for all source code in the repository.
|
5
|
+
#
|
6
|
+
# @see {Overcommit::Hook::Shared::IndexTags}
|
5
7
|
class IndexTags < Base
|
6
8
|
include Overcommit::Hook::Shared::IndexTags
|
7
9
|
end
|
@@ -2,6 +2,8 @@ require 'overcommit/hook/shared/index_tags'
|
|
2
2
|
|
3
3
|
module Overcommit::Hook::PostCommit
|
4
4
|
# Updates ctags index for all source code in the repository.
|
5
|
+
#
|
6
|
+
# @see {Overcommit::Hook::Shared::IndexTags}
|
5
7
|
class IndexTags < Base
|
6
8
|
include Overcommit::Hook::Shared::IndexTags
|
7
9
|
end
|
@@ -2,6 +2,8 @@ require 'overcommit/hook/shared/index_tags'
|
|
2
2
|
|
3
3
|
module Overcommit::Hook::PostMerge
|
4
4
|
# Updates ctags index for all source code in the repository.
|
5
|
+
#
|
6
|
+
# @see {Overcommit::Hook::Shared::IndexTags}
|
5
7
|
class IndexTags < Base
|
6
8
|
include Overcommit::Hook::Shared::IndexTags
|
7
9
|
end
|
@@ -2,6 +2,8 @@ require 'overcommit/hook/shared/index_tags'
|
|
2
2
|
|
3
3
|
module Overcommit::Hook::PostRewrite
|
4
4
|
# Updates ctags index for all source code in the repository.
|
5
|
+
#
|
6
|
+
# @see {Overcommit::Hook::Shared::IndexTags}
|
5
7
|
class IndexTags < Base
|
6
8
|
include Overcommit::Hook::Shared::IndexTags
|
7
9
|
|
@@ -3,8 +3,13 @@ module Overcommit::Hook::PreCommit
|
|
3
3
|
# Adapted from https://github.com/pre-commit/pre-commit-hooks
|
4
4
|
class CaseConflicts < Base
|
5
5
|
def run
|
6
|
-
|
7
|
-
|
6
|
+
repo_files = Set.new(applicable_files)
|
7
|
+
|
8
|
+
unless Overcommit::GitRepo.initial_commit?
|
9
|
+
paths = repo_files.map { |file| File.dirname(file) + File::SEPARATOR }
|
10
|
+
repo_files += Overcommit::GitRepo.list_files(paths)
|
11
|
+
end
|
12
|
+
|
8
13
|
conflict_hash = repo_files.classify(&:downcase).
|
9
14
|
select { |_, files| files.size > 1 }
|
10
15
|
conflict_files = applicable_files.
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Overcommit::Hook::PreCommit
|
2
|
-
# Runs `chamber secure` against any modified Chamber settings files
|
2
|
+
# Runs `chamber secure` against any modified Chamber settings files.
|
3
|
+
#
|
4
|
+
# @see https://github.com/thekompanee/chamber
|
3
5
|
class ChamberSecurity < Base
|
4
6
|
def run
|
5
7
|
result = execute(command + applicable_files)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Overcommit::Hook::PreCommit
|
2
2
|
# Runs `reek` against any modified Ruby files.
|
3
|
+
#
|
4
|
+
# @see https://github.com/troessner/reek
|
3
5
|
class Reek < Base
|
4
6
|
def run
|
5
7
|
result = execute(command + applicable_files)
|
@@ -9,7 +11,7 @@ module Overcommit::Hook::PreCommit
|
|
9
11
|
|
10
12
|
extract_messages(
|
11
13
|
output,
|
12
|
-
|
14
|
+
/^\s*(?<file>[^:]+):(?<line>\d+):/,
|
13
15
|
)
|
14
16
|
end
|
15
17
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Overcommit::Hook::Shared
|
2
2
|
# Shared code used by all IndexTags hooks. It runs ctags in the background so
|
3
3
|
# your tag definitions are up-to-date.
|
4
|
+
#
|
5
|
+
# @see http://ctags.sourceforge.net/
|
4
6
|
module IndexTags
|
5
7
|
def run
|
6
8
|
execute_in_background([Overcommit::Utils.script_path('index-tags')])
|
@@ -88,19 +88,27 @@ module Overcommit::HookContext
|
|
88
88
|
# Renames and deletions are ignored, since there should be nothing to check.
|
89
89
|
def modified_files
|
90
90
|
unless @modified_files
|
91
|
-
|
91
|
+
currently_staged = Overcommit::GitRepo.modified_files(staged: true)
|
92
|
+
@modified_files = currently_staged
|
92
93
|
|
93
94
|
# Include files modified in last commit if amending
|
94
95
|
if amendment?
|
95
96
|
subcmd = 'show --format=%n'
|
96
|
-
|
97
|
+
previously_modified = Overcommit::GitRepo.modified_files(subcmd: subcmd)
|
98
|
+
|
99
|
+
# Filter out non-existent files. This could happen if a file was
|
100
|
+
# renamed as part of the amendment, leading to the old file no longer
|
101
|
+
# existing.
|
102
|
+
previously_modified.select! { |file| File.exist?(file) }
|
97
103
|
|
98
104
|
# Filter out directories. This could happen when changing a symlink to
|
99
105
|
# a directory as part of an amendment, since the symlink will still
|
100
106
|
# appear as a file, but the actual working tree will have a directory.
|
101
|
-
|
107
|
+
previously_modified.reject! do |file|
|
102
108
|
File.directory?(file) && !File.symlink?(file)
|
103
109
|
end
|
110
|
+
|
111
|
+
@modified_files |= previously_modified
|
104
112
|
end
|
105
113
|
end
|
106
114
|
@modified_files
|
data/lib/overcommit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overcommit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.26.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brigade Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: childprocess
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/overcommit/hook/base.rb
|
106
106
|
- lib/overcommit/hook/commit_msg/base.rb
|
107
107
|
- lib/overcommit/hook/commit_msg/capitalized_subject.rb
|
108
|
+
- lib/overcommit/hook/commit_msg/empty_message.rb
|
108
109
|
- lib/overcommit/hook/commit_msg/gerrit_change_id.rb
|
109
110
|
- lib/overcommit/hook/commit_msg/hard_tabs.rb
|
110
111
|
- lib/overcommit/hook/commit_msg/russian_novel.rb
|