Skip to content

Commit 3219b60

Browse files
committed
forward cli options to hook context
1 parent 9ce5492 commit 3219b60

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

lib/overcommit/cli.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module Overcommit
99
class CLI # rubocop:disable Metrics/ClassLength
1010
def initialize(arguments, input, logger)
1111
@arguments = arguments
12+
@cli_options = {}
1213
@input = input
1314
@log = logger
1415
@options = {}
@@ -45,7 +46,7 @@ def parse_arguments
4546
@parser = create_option_parser
4647

4748
begin
48-
@parser.parse!(@arguments)
49+
@parser.parse!(@arguments, into: @cli_options)
4950

5051
# Default action is to install
5152
@options[:action] ||= :install

lib/overcommit/hook_context.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
# Utility module which manages the creation of {HookContext}s.
44
module Overcommit::HookContext
5-
def self.create(hook_type, config, args, input)
5+
def self.create(hook_type, config, args, input, **cli_options)
66
hook_type_class = Overcommit::Utils.camel_case(hook_type)
77
underscored_hook_type = Overcommit::Utils.snake_case(hook_type)
88

99
require "overcommit/hook_context/#{underscored_hook_type}"
1010

11-
Overcommit::HookContext.const_get(hook_type_class).new(config, args, input)
11+
Overcommit::HookContext.const_get(hook_type_class).new(config, args, input, **cli_options)
1212
rescue LoadError, NameError => e
1313
# Could happen when a symlink was created for a hook type Overcommit does
1414
# not yet support.

lib/overcommit/hook_context/base.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ class Base
1818
# @param config [Overcommit::Configuration]
1919
# @param args [Array<String>]
2020
# @param input [IO] standard input stream
21-
def initialize(config, args, input)
21+
# @param options [Hash] cli options
22+
def initialize(config, args, input, **options)
2223
@config = config
2324
@args = args
2425
@input = input
26+
@options = options
2527
end
2628

2729
# Executes a command as if it were a regular git hook, passing all

0 commit comments

Comments
 (0)