@@ -119,6 +119,14 @@ def enabled_builtin_hooks(hook_context)
119
119
select { |hook_name | hook_enabled? ( hook_context , hook_name ) }
120
120
end
121
121
122
+ # Returns the gem-provided hooks that have been enabled for a hook type.
123
+ def enabled_gem_hooks ( hook_context )
124
+ @hash [ hook_context . hook_class_name ] . keys .
125
+ reject { |hook_name | hook_name == 'ALL' } .
126
+ select { |hook_name | gem_hook? ( hook_context , hook_name ) } .
127
+ select { |hook_name | hook_enabled? ( hook_context , hook_name ) }
128
+ end
129
+
122
130
# Returns the ad hoc hooks that have been enabled for a hook type.
123
131
def enabled_ad_hoc_hooks ( hook_context )
124
132
@hash [ hook_context . hook_class_name ] . keys .
@@ -259,6 +267,7 @@ def ad_hoc_hook?(hook_context, hook_name)
259
267
# Ad hoc hooks are neither built-in nor have a plugin file written but
260
268
# still have a `command` specified to be run
261
269
!built_in_hook? ( hook_context , hook_name ) &&
270
+ !gem_hook? ( hook_context , hook_name ) &&
262
271
!plugin_hook? ( hook_context , hook_name ) &&
263
272
( ad_hoc_conf [ 'command' ] || ad_hoc_conf [ 'required_executable' ] )
264
273
end
@@ -270,8 +279,18 @@ def built_in_hook?(hook_context, hook_name)
270
279
hook_context . hook_type_name , "#{ hook_name } .rb" ) )
271
280
end
272
281
282
+ def gem_hook? ( hook_context , hook_name )
283
+ hook_name = Overcommit ::Utils . snake_case ( hook_name )
284
+
285
+ $LOAD_PATH. any? do |path |
286
+ File . exist? ( File . join ( path , 'overcommit' , 'hook' ,
287
+ hook_context . hook_type_name , "#{ hook_name } .rb" ) )
288
+ end
289
+ end
290
+
273
291
def hook_exists? ( hook_context , hook_name )
274
292
built_in_hook? ( hook_context , hook_name ) ||
293
+ gem_hook? ( hook_context , hook_name ) ||
275
294
plugin_hook? ( hook_context , hook_name ) ||
276
295
ad_hoc_hook? ( hook_context , hook_name )
277
296
end
0 commit comments