Skip to content

Commit b0480f0

Browse files
committed
Fix HardTabs pre-commit hook to use extract_messages
Similar to 06d5d75, we change `HardTabs` to use `extract_messages` so line information is captured.
1 parent 06d5d75 commit b0480f0

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

CHANGELOG.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
[Scalariform](https://mdr.github.io/scalariform/)
1212
* Add `SlimLint` pre-commit hook that analyzes Slim templates with
1313
[Slim-Lint](https://github.com/sds/slim-lint)
14-
* Enhance `TrailingWhitespace` pre-commit hook to including line information in
15-
errors, making it work as expected when `problem_on_unmodified_line` is set
16-
to something other than `report`
14+
* Enhance `HardTabs` and `TrailingWhitespace` pre-commit hooks to including
15+
line information in errors, making it work as expected when
16+
`problem_on_unmodified_line` is set to something other than `report`
1717

1818
## 0.24.0
1919

lib/overcommit/hook/pre_commit/hard_tabs.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ module Overcommit::Hook::PreCommit
22
# Checks for hard tabs in files.
33
class HardTabs < Base
44
def run
5-
# Catches hard tabs
65
result = execute(command + applicable_files)
7-
unless result.stdout.empty?
8-
return :fail, "Hard tabs detected:\n#{result.stdout}"
9-
end
106

11-
:pass
7+
extract_messages(
8+
result.stdout.split("\n"),
9+
/^(?<file>[^:]+):(?<line>\d+)/,
10+
)
1211
end
1312
end
1413
end

0 commit comments

Comments
 (0)