Class: AddWatermarkCommitHook
- Inherits:
-
RubyGitHooks::Hook
- Object
- RubyGitHooks::Hook
- AddWatermarkCommitHook
- Defined in:
- lib/ruby_git_hooks/watermark.rb
Overview
This hook adds a watermark to the end of commit message so that we know the hooks have been run. It should be run as the last commit-msg hook so it changes the message immediately before the commit is accepted and other hooks can’t remove the watermark afterward.
Constant Summary
Constants inherited from RubyGitHooks::Hook
RubyGitHooks::Hook::HOOK_INFO, RubyGitHooks::Hook::HOOK_TYPE_SETUP
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(mark = "\u00a0") ⇒ AddWatermarkCommitHook
constructor
A new instance of AddWatermarkCommitHook.
Methods inherited from RubyGitHooks::Hook
get_hooks_to_run, initial_setup, register, run, run_as_specific_githook, #setup, shell!
Constructor Details
#initialize(mark = "\u00a0") ⇒ AddWatermarkCommitHook
Returns a new instance of AddWatermarkCommitHook.
13 14 15 |
# File 'lib/ruby_git_hooks/watermark.rb', line 13 def initialize(mark = "\u00a0") @watermark = mark end |
Instance Method Details
#check ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/ruby_git_hooks/watermark.rb', line 17 def check if ! STDERR.puts "Warning: Watermark hook must be run as commit-msg only" return true # don't actually cause commit to fail end File.open(, 'a') {|f| f.write(@watermark)} return true end |