Class: Overcommit::HookSigner
- Inherits:
-
Object
- Object
- Overcommit::HookSigner
- Defined in:
- lib/overcommit/hook_signer.rb
Overview
Calculates, stores, and retrieves stored signatures of hook plugins.
Constant Summary collapse
- IGNORED_CONFIG_KEYS =
We don’t want to include the skip setting as it is set by Overcommit itself
%w[skip]
Instance Attribute Summary collapse
-
#hook_name ⇒ Object
readonly
Returns the value of attribute hook_name.
-
#hook_path ⇒ Object
readonly
Returns the value of attribute hook_path.
Instance Method Summary collapse
-
#initialize(hook_path, config, context) ⇒ HookSigner
constructor
A new instance of HookSigner.
-
#signature_changed? ⇒ true, false
Return whether the signature for this hook has changed since it was last calculated.
-
#update_signature! ⇒ Object
Update the current stored signature for this hook.
Constructor Details
#initialize(hook_path, config, context) ⇒ HookSigner
Returns a new instance of HookSigner.
13 14 15 16 17 18 19 |
# File 'lib/overcommit/hook_signer.rb', line 13 def initialize(hook_path, config, context) @hook_path = hook_path @config = config @context = context @hook_name = Overcommit::Utils.camel_case(File.basename(@hook_path, '.rb')) end |
Instance Attribute Details
#hook_name ⇒ Object (readonly)
Returns the value of attribute hook_name.
4 5 6 |
# File 'lib/overcommit/hook_signer.rb', line 4 def hook_name @hook_name end |
#hook_path ⇒ Object (readonly)
Returns the value of attribute hook_path.
4 5 6 |
# File 'lib/overcommit/hook_signer.rb', line 4 def hook_path @hook_path end |
Instance Method Details
#signature_changed? ⇒ true, false
Return whether the signature for this hook has changed since it was last calculated.
25 26 27 |
# File 'lib/overcommit/hook_signer.rb', line 25 def signature_changed? signature != stored_signature end |
#update_signature! ⇒ Object
Update the current stored signature for this hook.
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/overcommit/hook_signer.rb', line 30 def update_signature! result = Overcommit::Utils.execute( %w[git config --local] + [signature_config_key, signature] ) unless result.success? raise Overcommit::Exceptions::GitConfigError, "Unable to write to local repo git config: #{result.stderr}" end end |