overcommit 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a23b361b3bac1357e190f81ea1912710b9bd62bf
4
- data.tar.gz: d0d707d8f82ed50aff865fd170b769baf8d78869
3
+ metadata.gz: 7c3cf160d0c937fd468fe3b7324ab79f9c567c2d
4
+ data.tar.gz: 9e149912787db4bf6e259e7517f688fce95f14c6
5
5
  SHA512:
6
- metadata.gz: a7a1110c6239f00662de316e677dab141db03ae87f9c13eca2c2a0dc2b78ed5b3bb41cbbf0d4c11a79436423b0a3cda2215de6a4d926c7b3a48e0b4ab586e1ca
7
- data.tar.gz: 408ac82b4911e94f48670c674870eb79acfd93109f2edd1ca19993c49f6a40f193161a8cd1f26ec7b4121ee66e0391f3ce12715a332152bca128636ec218476d
6
+ metadata.gz: 16a6eaf4ea1ce8f03bcdfd7bf7b331c2e5a8b2c6c2c896aa10bbae88864a588741806325aa1a4a60c29a3021ef41db7d1a0573bb9c5fa9f76db10e05bea349a8
7
+ data.tar.gz: acf3efe320ede57d9d933f47b187e61c03a5e35646884da3f3fcfbc1f932dc3079d992b6016ba15128af301e27dd379c6aeae5f98829abd119f895902420eb88
@@ -19,10 +19,11 @@ module Overcommit
19
19
  end
20
20
 
21
21
  # Returns the built-in hooks that have been enabled for a hook type.
22
- def enabled_builtin_hooks(hook_type)
23
- @hash[hook_type].keys.
22
+ def enabled_builtin_hooks(hook_context)
23
+ @hash[hook_context.hook_class_name].keys.
24
24
  select { |hook_name| hook_name != 'ALL' }.
25
- select { |hook_name| hook_enabled?(hook_type, hook_name) }
25
+ select { |hook_name| built_in_hook?(hook_context, hook_name) }.
26
+ select { |hook_name| hook_enabled?(hook_context, hook_name) }
26
27
  end
27
28
 
28
29
  # Returns a non-modifiable configuration for a hook.
@@ -46,13 +47,14 @@ module Overcommit
46
47
 
47
48
  # Applies additional configuration settings based on the provided
48
49
  # environment variables.
49
- def apply_environment!(hook_type, env)
50
+ def apply_environment!(hook_context, env)
50
51
  skipped_hooks = "#{env['SKIP']} #{env['SKIP_CHECKS']} #{env['SKIP_HOOKS']}".split(/[:, ]/)
52
+ hook_type = hook_context.hook_class_name
51
53
 
52
54
  if skipped_hooks.include?('all') || skipped_hooks.include?('ALL')
53
55
  @hash[hook_type]['ALL']['skip'] = true
54
56
  else
55
- skipped_hooks.select { |hook_name| hook_exists?(hook_type, hook_name) }.
57
+ skipped_hooks.select { |hook_name| hook_exists?(hook_context, hook_name) }.
56
58
  map { |hook_name| Overcommit::Utils.camel_case(hook_name) }.
57
59
  each do |hook_name|
58
60
  @hash[hook_type][hook_name] ||= {}
@@ -67,15 +69,28 @@ module Overcommit
67
69
 
68
70
  private
69
71
 
70
- def hook_exists?(hook_type, hook_name)
72
+ def built_in_hook?(hook_context, hook_name)
71
73
  hook_name = Overcommit::Utils.snake_case(hook_name)
72
- underscored_hook_type = Overcommit::Utils.snake_case(hook_type)
73
74
 
74
75
  File.exist?(File.join(OVERCOMMIT_HOME, 'lib', 'overcommit', 'hook',
75
- underscored_hook_type, "#{hook_name}.rb"))
76
+ hook_context.hook_type_name, "#{hook_name}.rb"))
76
77
  end
77
78
 
78
- def hook_enabled?(hook_type, hook_name)
79
+ def plugin_hook?(hook_context, hook_name)
80
+ hook_name = Overcommit::Utils.snake_case(hook_name)
81
+
82
+ File.exist?(File.join(plugin_directory,
83
+ hook_context.hook_type_name,
84
+ "#{hook_name}.rb"))
85
+ end
86
+
87
+ def hook_exists?(hook_context, hook_name)
88
+ built_in_hook?(hook_context, hook_name) ||
89
+ plugin_hook?(hook_context, hook_name)
90
+ end
91
+
92
+ def hook_enabled?(hook_context, hook_name)
93
+ hook_type = hook_context.hook_class_name
79
94
  individual_enabled = @hash[hook_type][hook_name]['enabled']
80
95
  return individual_enabled unless individual_enabled.nil?
81
96
 
@@ -1,11 +1,12 @@
1
1
  # Utility module which manages the creation of {HookContext}s.
2
2
  module Overcommit::HookContext
3
3
  def self.create(hook_type, config, args, input)
4
+ hook_type_class = Overcommit::Utils.camel_case(hook_type)
4
5
  underscored_hook_type = Overcommit::Utils.snake_case(hook_type)
5
6
 
6
7
  require "overcommit/hook_context/#{underscored_hook_type}"
7
8
 
8
- Overcommit::HookContext.const_get(hook_type).new(config, args, input)
9
+ Overcommit::HookContext.const_get(hook_type_class).new(config, args, input)
9
10
  rescue LoadError, NameError => error
10
11
  # Could happen when a symlink was created for a hook type Overcommit does
11
12
  # not yet support.
@@ -116,7 +116,7 @@ module Overcommit
116
116
  # Load hooks that ship with Overcommit, ignoring ones that are excluded from
117
117
  # the repository's configuration.
118
118
  def load_builtin_hooks
119
- @config.enabled_builtin_hooks(@context.hook_class_name).each do |hook_name|
119
+ @config.enabled_builtin_hooks(@context).each do |hook_name|
120
120
  underscored_hook_name = Overcommit::Utils.snake_case(hook_name)
121
121
  require "overcommit/hook/#{@context.hook_type_name}/#{underscored_hook_name}"
122
122
  @hooks << create_hook(hook_name)
@@ -1,3 +1,4 @@
1
+ # Defines the gem version.
1
2
  module Overcommit
2
- VERSION = '0.6.0'
3
+ VERSION = '0.6.1'
3
4
  end
@@ -49,16 +49,11 @@ if Gem::Version.new(Overcommit::VERSION) < Gem::Version.new('0.6.0')
49
49
  end
50
50
 
51
51
  begin
52
- hook_type_class = Overcommit::Utils.camel_case(hook_type)
53
-
54
52
  config = Overcommit::ConfigurationLoader.load_repo_config
55
- config.apply_environment!(hook_type_class, ENV)
56
53
 
57
- # Ensure this script and all symlinks are always up-to-date (it's cheap to do)
58
- Overcommit::Installer.new(Overcommit::Logger.silent).
59
- run(Overcommit::Utils.repo_root, :action => :install)
54
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
55
+ config.apply_environment!(context, ENV)
60
56
 
61
- context = Overcommit::HookContext.create(hook_type_class, config, ARGV, STDIN)
62
57
  logger = Overcommit::Logger.new(STDOUT)
63
58
  runner = Overcommit::HookRunner.new(config, logger, context)
64
59
 
@@ -49,16 +49,11 @@ if Gem::Version.new(Overcommit::VERSION) < Gem::Version.new('0.6.0')
49
49
  end
50
50
 
51
51
  begin
52
- hook_type_class = Overcommit::Utils.camel_case(hook_type)
53
-
54
52
  config = Overcommit::ConfigurationLoader.load_repo_config
55
- config.apply_environment!(hook_type_class, ENV)
56
53
 
57
- # Ensure this script and all symlinks are always up-to-date (it's cheap to do)
58
- Overcommit::Installer.new(Overcommit::Logger.silent).
59
- run(Overcommit::Utils.repo_root, :action => :install)
54
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
55
+ config.apply_environment!(context, ENV)
60
56
 
61
- context = Overcommit::HookContext.create(hook_type_class, config, ARGV, STDIN)
62
57
  logger = Overcommit::Logger.new(STDOUT)
63
58
  runner = Overcommit::HookRunner.new(config, logger, context)
64
59
 
@@ -49,16 +49,11 @@ if Gem::Version.new(Overcommit::VERSION) < Gem::Version.new('0.6.0')
49
49
  end
50
50
 
51
51
  begin
52
- hook_type_class = Overcommit::Utils.camel_case(hook_type)
53
-
54
52
  config = Overcommit::ConfigurationLoader.load_repo_config
55
- config.apply_environment!(hook_type_class, ENV)
56
53
 
57
- # Ensure this script and all symlinks are always up-to-date (it's cheap to do)
58
- Overcommit::Installer.new(Overcommit::Logger.silent).
59
- run(Overcommit::Utils.repo_root, :action => :install)
54
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
55
+ config.apply_environment!(context, ENV)
60
56
 
61
- context = Overcommit::HookContext.create(hook_type_class, config, ARGV, STDIN)
62
57
  logger = Overcommit::Logger.new(STDOUT)
63
58
  runner = Overcommit::HookRunner.new(config, logger, context)
64
59
 
@@ -49,16 +49,11 @@ if Gem::Version.new(Overcommit::VERSION) < Gem::Version.new('0.6.0')
49
49
  end
50
50
 
51
51
  begin
52
- hook_type_class = Overcommit::Utils.camel_case(hook_type)
53
-
54
52
  config = Overcommit::ConfigurationLoader.load_repo_config
55
- config.apply_environment!(hook_type_class, ENV)
56
53
 
57
- # Ensure this script and all symlinks are always up-to-date (it's cheap to do)
58
- Overcommit::Installer.new(Overcommit::Logger.silent).
59
- run(Overcommit::Utils.repo_root, :action => :install)
54
+ context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
55
+ config.apply_environment!(context, ENV)
60
56
 
61
- context = Overcommit::HookContext.create(hook_type_class, config, ARGV, STDIN)
62
57
  logger = Overcommit::Logger.new(STDOUT)
63
58
  runner = Overcommit::HookRunner.new(config, logger, context)
64
59
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Causes Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-20 00:00:00.000000000 Z
12
+ date: 2014-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: wopen3