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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.yml +5 -0
  3. data/config/starter.yml +1 -1
  4. data/lib/overcommit/configuration.rb +6 -2
  5. data/lib/overcommit/git_repo.rb +1 -1
  6. data/lib/overcommit/hook/base.rb +28 -27
  7. data/lib/overcommit/hook/commit_msg/empty_message.rb +10 -0
  8. data/lib/overcommit/hook/commit_msg/gerrit_change_id.rb +2 -0
  9. data/lib/overcommit/hook/commit_msg/spell_check.rb +3 -1
  10. data/lib/overcommit/hook/post_checkout/index_tags.rb +2 -0
  11. data/lib/overcommit/hook/post_commit/git_guilt.rb +2 -0
  12. data/lib/overcommit/hook/post_commit/index_tags.rb +2 -0
  13. data/lib/overcommit/hook/post_merge/index_tags.rb +2 -0
  14. data/lib/overcommit/hook/post_rewrite/index_tags.rb +2 -0
  15. data/lib/overcommit/hook/pre_commit/berksfile_check.rb +2 -0
  16. data/lib/overcommit/hook/pre_commit/brakeman.rb +2 -0
  17. data/lib/overcommit/hook/pre_commit/bundle_check.rb +2 -0
  18. data/lib/overcommit/hook/pre_commit/case_conflicts.rb +7 -2
  19. data/lib/overcommit/hook/pre_commit/chamber_security.rb +3 -1
  20. data/lib/overcommit/hook/pre_commit/coffee_lint.rb +2 -0
  21. data/lib/overcommit/hook/pre_commit/css_lint.rb +2 -0
  22. data/lib/overcommit/hook/pre_commit/es_lint.rb +2 -0
  23. data/lib/overcommit/hook/pre_commit/go_lint.rb +2 -0
  24. data/lib/overcommit/hook/pre_commit/go_vet.rb +2 -0
  25. data/lib/overcommit/hook/pre_commit/haml_lint.rb +2 -0
  26. data/lib/overcommit/hook/pre_commit/html_tidy.rb +2 -0
  27. data/lib/overcommit/hook/pre_commit/image_optim.rb +2 -0
  28. data/lib/overcommit/hook/pre_commit/java_checkstyle.rb +2 -0
  29. data/lib/overcommit/hook/pre_commit/js_hint.rb +2 -0
  30. data/lib/overcommit/hook/pre_commit/js_lint.rb +2 -0
  31. data/lib/overcommit/hook/pre_commit/jscs.rb +2 -0
  32. data/lib/overcommit/hook/pre_commit/jsl.rb +2 -0
  33. data/lib/overcommit/hook/pre_commit/pep257.rb +2 -0
  34. data/lib/overcommit/hook/pre_commit/pep8.rb +2 -0
  35. data/lib/overcommit/hook/pre_commit/pyflakes.rb +2 -0
  36. data/lib/overcommit/hook/pre_commit/pylint.rb +2 -0
  37. data/lib/overcommit/hook/pre_commit/python_flake8.rb +2 -0
  38. data/lib/overcommit/hook/pre_commit/reek.rb +3 -1
  39. data/lib/overcommit/hook/pre_commit/rubo_cop.rb +2 -0
  40. data/lib/overcommit/hook/pre_commit/ruby_lint.rb +2 -0
  41. data/lib/overcommit/hook/pre_commit/scalariform.rb +2 -0
  42. data/lib/overcommit/hook/pre_commit/scalastyle.rb +2 -0
  43. data/lib/overcommit/hook/pre_commit/scss_lint.rb +2 -0
  44. data/lib/overcommit/hook/pre_commit/semi_standard.rb +2 -0
  45. data/lib/overcommit/hook/pre_commit/shell_check.rb +2 -0
  46. data/lib/overcommit/hook/pre_commit/slim_lint.rb +2 -0
  47. data/lib/overcommit/hook/pre_commit/standard.rb +2 -0
  48. data/lib/overcommit/hook/pre_commit/travis_lint.rb +2 -0
  49. data/lib/overcommit/hook/pre_commit/vint.rb +2 -0
  50. data/lib/overcommit/hook/pre_commit/w3c_css.rb +2 -0
  51. data/lib/overcommit/hook/pre_commit/w3c_html.rb +2 -0
  52. data/lib/overcommit/hook/pre_commit/xml_lint.rb +2 -0
  53. data/lib/overcommit/hook/pre_push/r_spec.rb +2 -0
  54. data/lib/overcommit/hook/pre_rebase/base.rb +2 -1
  55. data/lib/overcommit/hook/shared/index_tags.rb +2 -0
  56. data/lib/overcommit/hook_context/pre_commit.rb +11 -3
  57. data/lib/overcommit/version.rb +1 -1
  58. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bbe6329a0cba58948e9ee76c415c994a7853076e
4
- data.tar.gz: 8ccb39fc02ed962de60f1dd89398ed77e6c63187
3
+ metadata.gz: 9f071e1a8038ef082833913a8eb83e6bfb44b371
4
+ data.tar.gz: eb442b2dc4457f8173f9fff48572f575839c39e9
5
5
  SHA512:
6
- metadata.gz: 8239e6a77a599153d4f6d30a23b329f7aa6d2c6b46ed001ce9dc1b0f4a3014b17fa65de8f8b004956271d989eb9a200dee2ee67ebb782e1bfa82b60fa2623744
7
- data.tar.gz: 2e569ffcb8e328e0033913866e12230674b6ff42df2c955df0d0e87b0bdaa03fc0e628628bae01b42e68ba471d5cdb3b1ff26862c9baffc0916f3e9d550b7ab4
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
@@ -16,7 +16,7 @@
16
16
  # Uncomment the following lines to make the configuration take effect.
17
17
 
18
18
  #PreCommit:
19
- # Rubocop:
19
+ # RuboCop:
20
20
  # on_warn: fail # Treat all warnings as failures
21
21
  #
22
22
  # TrailingWhitespace:
@@ -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 = hook_context_or_type.is_a?(String) ? hook_context_or_type :
166
- hook_context_or_type.hook_class_name
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?
@@ -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
@@ -42,38 +42,13 @@ module Overcommit::Hook
42
42
  if output = check_for_requirements
43
43
  status = :fail
44
44
  else
45
- status, output = process_hook_return_value(run)
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.
@@ -0,0 +1,10 @@
1
+ module Overcommit::Hook::CommitMsg
2
+ # Checks that the commit message is not empty
3
+ class EmptyMessage < Base
4
+ def run
5
+ return :pass unless empty_message?
6
+
7
+ [:fail, 'Commit message should not be empty']
8
+ end
9
+ end
10
+ end
@@ -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
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PostCommit
2
2
  # Calculates the change in blame since the last revision.
3
+ #
4
+ # @see https://www.npmjs.com/package/git-guilt
3
5
  class GitGuilt < Base
4
6
  PLUS_MINUS_REGEX = /^(.*?)(?:(\++)|(-+))$/
5
7
  GREEN = 32
@@ -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
 
@@ -1,6 +1,8 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Check if local Berksfile.lock matches Berksfile when either changes, unless
3
3
  # Berksfile.lock is ignored by git.
4
+ #
5
+ # @see http://berkshelf.com/
4
6
  class BerksfileCheck < Base
5
7
  LOCK_FILE = 'Berksfile.lock'
6
8
 
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `brakeman` against any modified Ruby/Rails files.
3
+ #
4
+ # @see http://brakemanscanner.org/
3
5
  class Brakeman < Base
4
6
  def run
5
7
  result = execute(command + [applicable_files.join(',')])
@@ -1,6 +1,8 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Check if local Gemfile.lock matches Gemfile when either changes, unless
3
3
  # Gemfile.lock is ignored by git.
4
+ #
5
+ # @see http://bundler.io/
4
6
  class BundleCheck < Base
5
7
  LOCK_FILE = 'Gemfile.lock'
6
8
 
@@ -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
- paths = Set.new(applicable_files.map { |file| File.dirname(file) + File::SEPARATOR })
7
- repo_files = Set.new(Overcommit::GitRepo.list_files(paths.to_a) + applicable_files)
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 `coffeelint` against any modified CoffeeScript files.
3
+ #
4
+ # @see http://www.coffeelint.org/
3
5
  class CoffeeLint < 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 `csslint` against any modified CSS files.
3
+ #
4
+ # @see https://github.com/CSSLint/csslint
3
5
  class CssLint < Base
4
6
  MESSAGE_REGEX = /
5
7
  ^(?<file>[^:]+):\s
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `eslint` against any modified JavaScript files.
3
+ #
4
+ # @see http://eslint.org/
3
5
  class EsLint < 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 `golint` against any modified Golang files.
3
+ #
4
+ # @see https://github.com/golang/lint
3
5
  class GoLint < 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 `go vet` against any modified Golang files.
3
+ #
4
+ # @see https://godoc.org/code.google.com/p/go-zh.tools/cmd/vet
3
5
  class GoVet < 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 `haml-lint` against any modified HAML files.
3
+ #
4
+ # @see https://github.com/brigade/haml-lint/
3
5
  class HamlLint < Base
4
6
  MESSAGE_TYPE_CATEGORIZER = lambda do |type|
5
7
  type.include?('W') ? :warning : :error
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `tidy` against any modified HTML files.
3
+ #
4
+ # @see http://www.html-tidy.org/
3
5
  class HtmlTidy < Base
4
6
  MESSAGE_REGEX = /
5
7
  ^(?<file>[^:]+):\s
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Checks for images that can be optimized with `image_optim`.
3
+ #
4
+ # @see https://github.com/toy/image_optim
3
5
  class ImageOptim < 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 `checkstyle` against any modified Java files.
3
+ #
4
+ # @see http://checkstyle.sourceforge.net/
3
5
  class JavaCheckstyle < Base
4
6
  MESSAGE_REGEX = /^(?<file>[^:]+):(?<line>\d+)/
5
7
 
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `jshint` against any modified JavaScript files.
3
+ #
4
+ # @see http://jshint.com/
3
5
  class JsHint < 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 `jslint` against any modified JavaScript files.
3
+ #
4
+ # @see http://www.jslint.com/
3
5
  class JsLint < Base
4
6
  MESSAGE_REGEX = /(?<file>[^:]+):(?<line>\d+)/
5
7
 
@@ -1,6 +1,8 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `jscs` (JavaScript Code Style Checker) against any modified JavaScript
3
3
  # files.
4
+ #
5
+ # @see http://jscs.info/
4
6
  class Jscs < Base
5
7
  def run
6
8
  result = execute(command + applicable_files)
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `jsl` against any modified JavaScript files.
3
+ #
4
+ # @see http://www.javascriptlint.com/
3
5
  class Jsl < Base
4
6
  MESSAGE_REGEX = /(?<file>.+)\((?<line>\d+)\):(?<type>[^:]+)/
5
7
 
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `pep257` against any modified Python files.
3
+ #
4
+ # @see https://pypi.python.org/pypi/pep257
3
5
  class Pep257 < 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 `pep8` against any modified Python files.
3
+ #
4
+ # @see https://pypi.python.org/pypi/pep8
3
5
  class Pep8 < 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 `pyflakes` against any modified Python files.
3
+ #
4
+ # @see https://pypi.python.org/pypi/pyflakes
3
5
  class Pyflakes < Base
4
6
  MESSAGE_REGEX = /^(?<file>[^:]+):(?<line>\d+):/
5
7
 
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `pylint` against any modified Python files.
3
+ #
4
+ # @see http://www.pylint.org/
3
5
  class Pylint < Base
4
6
  MESSAGE_REGEX = /^(?<file>.+):(?<line>\d+):(?<type>[CEFRW])/
5
7
 
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `flake8` against any modified Python files.
3
+ #
4
+ # @see https://pypi.python.org/pypi/flake8
3
5
  class PythonFlake8 < Base
4
6
  MESSAGE_REGEX = /^(?<file>.+):(?<line>\d+):\d+:\s(?<type>\w\d+)/
5
7
 
@@ -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
- /^(?<file>[^:]+):(?<line>\d+):/,
14
+ /^\s*(?<file>[^:]+):(?<line>\d+):/,
13
15
  )
14
16
  end
15
17
 
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `rubocop` against any modified Ruby files.
3
+ #
4
+ # @see http://batsov.com/rubocop/
3
5
  class RuboCop < Base
4
6
  MESSAGE_TYPE_CATEGORIZER = lambda do |type|
5
7
  type.include?('W') ? :warning : :error
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `ruby-lint` against any modified Ruby files.
3
+ #
4
+ # @see https://github.com/YorickPeterse/ruby-lint
3
5
  class RubyLint < Base
4
6
  MESSAGE_TYPE_CATEGORIZER = lambda do |type|
5
7
  type.include?('W') ? :warning : :error
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `scalariform` against any modified Scala files.
3
+ #
4
+ # @see https://github.com/mdr/scalariform
3
5
  class Scalariform < Base
4
6
  MESSAGE_REGEX = /^\[(?<type>FAILED|ERROR)\]\s+(?<file>.+)/
5
7
 
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `scalastyle` against any modified Scala files.
3
+ #
4
+ # @see http://www.scalastyle.org/
3
5
  class Scalastyle < Base
4
6
  MESSAGE_REGEX = /
5
7
  ^(?<type>error|warning)\s
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `scss-lint` against any modified SCSS files.
3
+ #
4
+ # @see https://github.com/brigade/scss-lint
3
5
  class ScssLint < Base
4
6
  MESSAGE_TYPE_CATEGORIZER = lambda do |type|
5
7
  type.include?('W') ? :warning : :error
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `semistandard` against any modified JavaScript files.
3
+ #
4
+ # @see https://github.com/Flet/semistandard
3
5
  class SemiStandard < 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 `shellcheck` against any modified shell script files.
3
+ #
4
+ # @see http://www.shellcheck.net/
3
5
  class ShellCheck < Base
4
6
  MESSAGE_TYPE_CATEGORIZER = lambda do |type|
5
7
  type.include?('note') ? :warning : :error
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `slim-lint` against any modified Slim templates.
3
+ #
4
+ # @see https://github.com/sds/slim-lint
3
5
  class SlimLint < Base
4
6
  MESSAGE_TYPE_CATEGORIZER = lambda do |type|
5
7
  type.include?('W') ? :warning : :error
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `standard` against any modified JavaScript files.
3
+ #
4
+ # @see https://github.com/feross/standard
3
5
  class Standard < 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 `travis-lint` against any modified Travis CI files.
3
+ #
4
+ # @see https://github.com/travis-ci/travis.rb
3
5
  class TravisLint < 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 `vint` against any modified Vim script files.
3
+ #
4
+ # @see https://github.com/Kuniwak/vint
3
5
  class Vint < 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 `w3c_validators` against any modified CSS files.
3
+ #
4
+ # @see https://github.com/alexdunae/w3c_validators
3
5
  class W3cCss < Base
4
6
  def run
5
7
  collect_messages
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `w3c_validators` against any modified HTML files.
3
+ #
4
+ # @see https://github.com/alexdunae/w3c_validators
3
5
  class W3cHtml < Base
4
6
  def run
5
7
  collect_messages
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PreCommit
2
2
  # Runs `xmllint` against any modified XML files.
3
+ #
4
+ # @see http://xmlsoft.org/xmllint.html
3
5
  class XmlLint < Base
4
6
  MESSAGE_REGEX = /^(?<file>[^:]+):(?<line>\d+):/
5
7
 
@@ -1,5 +1,7 @@
1
1
  module Overcommit::Hook::PrePush
2
2
  # Runs `rspec` test suite before push
3
+ #
4
+ # @see http://rspec.info/
3
5
  class RSpec < Base
4
6
  def run
5
7
  result = execute(command)
@@ -6,6 +6,7 @@ module Overcommit::Hook::PreRebase
6
6
  extend Forwardable
7
7
 
8
8
  def_delegators :@context,
9
- :upstream_branch, :rebased_branch, :fast_forward?, :rebased_commits
9
+ :upstream_branch, :rebased_branch, :detached_head?,
10
+ :fast_forward?, :rebased_commits
10
11
  end
11
12
  end
@@ -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
- @modified_files = Overcommit::GitRepo.modified_files(staged: true)
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
- @modified_files += Overcommit::GitRepo.modified_files(subcmd: subcmd)
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
- @modified_files.reject! do |file|
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
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Overcommit
3
- VERSION = '0.25.0'
3
+ VERSION = '0.26.0'
4
4
  end
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.25.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-05-02 00:00:00.000000000 Z
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