overcommit 0.29.0 → 0.29.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: b3062f9af5dd34f661b3a2fe4c57dff0455c58fc
4
- data.tar.gz: 2a701f3f869be66540221aae63f3276f829b9d0d
3
+ metadata.gz: 91af002cf7828227351dd72b5c6bf2b27e3b217d
4
+ data.tar.gz: 025444e49ce27a05f6fc54134ae0ce70a466f851
5
5
  SHA512:
6
- metadata.gz: 863155a463f38f3fb09c915a61d7e91e175ebeda1da177076bcdf8fbadcda30ea5908995e227b15c8162bffab6ee0236224655196e03d214411f257c1acf1a39
7
- data.tar.gz: 841020568579082d8887466e0b4089759fc36f89f8f498c12fe2eaeb319737a0406bec7c82bdec0646aa49a405b85e025f31c81602d352b54c9af6bfe442cd36
6
+ metadata.gz: 602cf07b0687009d092330706d3f6d54179d2cbfcd1d58fb3cfa3c9fe92195ee1a0af3d452d5649666e534d5d352ab2ca52d5dd1711bda55ec1f20d7bc5fbbcc
7
+ data.tar.gz: 642bc0ec26c0af5dcfa44a30ea930f847f1cda71dd6bcd0d78003624f5b10c3c227918dea4d68d110c4b5844e7c40fe2a4538848685d185f28297516bddc4f62
@@ -95,7 +95,7 @@ module Overcommit
95
95
  end
96
96
 
97
97
  def add_other_options(opts)
98
- opts.on('-s', '--sign', 'Update hook signatures') do |hook_to_sign|
98
+ opts.on('-s', '--sign [hook]', 'Update hook signatures', String) do |hook_to_sign|
99
99
  @options[:hook_to_sign] = hook_to_sign if hook_to_sign.is_a?(String)
100
100
  @options[:action] = :sign
101
101
  end
@@ -14,6 +14,7 @@ module Overcommit
14
14
 
15
15
  hash = convert_nils_to_empty_hashes(hash)
16
16
  ensure_hook_type_sections_exist(hash)
17
+ check_hook_name_format(hash)
17
18
  check_for_missing_enabled_option(hash) unless @options[:default]
18
19
  check_for_verify_plugin_signatures_option(hash)
19
20
 
@@ -48,6 +49,31 @@ module Overcommit
48
49
  end
49
50
  end
50
51
 
52
+ # Prints an error message and raises an exception if a hook has an
53
+ # invalid name, since this can result in strange errors elsewhere.
54
+ def check_hook_name_format(hash)
55
+ errors = []
56
+
57
+ Overcommit::Utils.supported_hook_type_classes.each do |hook_type|
58
+ hash.fetch(hook_type, {}).each do |hook_name, _|
59
+ next if hook_name == 'ALL'
60
+
61
+ unless hook_name =~ /\A[A-Za-z0-9]+\z/
62
+ errors << "#{hook_type}::#{hook_name} has an invalid name " \
63
+ "#{hook_name}. It must contain only alphanumeric " \
64
+ 'characters (no underscores or dashes, etc.)'
65
+ end
66
+ end
67
+ end
68
+
69
+ if errors.any?
70
+ @log.error errors.join("\n") if @log
71
+ @log.newline if @log
72
+ raise Overcommit::Exceptions::ConfigurationError,
73
+ 'One or more hooks had invalid names'
74
+ end
75
+ end
76
+
51
77
  # Prints a warning if there are any hooks listed in the configuration
52
78
  # without `enabled` explicitly set.
53
79
  def check_for_missing_enabled_option(hash)
@@ -11,13 +11,15 @@ module Overcommit::Hook::PreCommit
11
11
  ignored_files = execute(%w[git ls-files -o -i --exclude-standard]).stdout.split("\n")
12
12
  return :pass if ignored_files.include?(LOCK_FILE)
13
13
 
14
+ previous_lockfile = File.read(LOCK_FILE) if File.exist?(LOCK_FILE)
15
+
14
16
  result = execute(command)
15
17
  unless result.success?
16
18
  return :fail, result.stdout
17
19
  end
18
20
 
19
- result = execute(%w[git diff --quiet --] + [LOCK_FILE])
20
- unless result.success?
21
+ new_lockfile = File.read(LOCK_FILE) if File.exist?(LOCK_FILE)
22
+ if previous_lockfile != new_lockfile
21
23
  return :fail, "#{LOCK_FILE} is not up-to-date -- run `#{command.join(' ')}`"
22
24
  end
23
25
 
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Overcommit
3
- VERSION = '0.29.0'
3
+ VERSION = '0.29.1'
4
4
  end
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.29.0
4
+ version: 0.29.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brigade Engineering