Plugin doesn't seem to be loaded
jbehrens94 opened this issue · comments
Johann Behrens commented
Hi all,
First of all, thank you for your work on this awesome open source tool. I'm setting up a simple plugin that checks source files for those ugly default Xcode header templates. This is what I did:
- Added
overcommit
to my Gemfile - Ran
overcommit --install
- Added my plugin to the
.git-hooks/pre_commit
folder - Added my custom configuration to the
.overcommit.yml
configuration file - Ran
overcommit --sign
andovercommit --sign pre-commit
- Committed my changes, but I don't see the plugin used in the output from
overcommit
.
Overcommit YML config
PreCommit:
NoXcodeTemplateComments:
description: 'Checking for Xcode template comments'
enabled: true
quiet: true
exclude:
- 'Pods/**/*.*'
include:
- '**/*.h'
- '**/*.m'
- '**/*.c'
- '**/*.cpp'
- '**/*.swift'
Overcommit plugin code
module Overcommit::Hook::PreCommit
class NoXcodeTemplateComments < Base
def run
errors = []
boilerplate = ['Created by', 'Copyright']
applicable_files.each do |file|
File.open(file, 'r').each_with_index do |line, index|
break if index > 10
boilerplate.each do |text|
comment = "// #{text} "
if line.start_with?(comment)
relative = Pathname(file).relative_path_from(Pathname(Overcommit::Utils.repo_root))
errors << "#{relative}:#{index} starts with #{comment}"
end
end
end
end
return :fail, errors.join("\n") if errors.any?
:pass
end
end
end
Output
Running pre-commit hooks
✓ All pre-commit hooks passed
Running commit-msg hooks
Check subject line................................[SingleLineSubject] OK
Check text width..........................................[TextWidth] OK
Check subject capitalization.....................[CapitalizedSubject] OK
Check for trailing periods in subject................[TrailingPeriod] OK
✓ All commit-msg hooks passed
Johann Behrens commented
Hi @sds,
Any idea on this issue? Would be cool to get your eyes on it.
Johann Behrens commented
Of course, 2 minutes after typing up the issue, I see it working. Closing this issue :)