overcommit 0.33.0 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/default.yml +10 -1
- data/lib/overcommit/hook/commit_msg/capitalized_subject.rb +9 -2
- data/lib/overcommit/hook/commit_msg/text_width.rb +7 -1
- data/lib/overcommit/hook/pre_commit/bundle_outdated.rb +23 -0
- data/lib/overcommit/hook/pre_commit/coffee_lint.rb +1 -0
- data/lib/overcommit/hook/pre_commit/es_lint.rb +4 -1
- data/lib/overcommit/hook/pre_commit/scalastyle.rb +2 -2
- data/lib/overcommit/hook/pre_push/protected_branches.rb +13 -1
- data/lib/overcommit/utils.rb +6 -4
- data/lib/overcommit/version.rb +1 -1
- data/template-dir/hooks/commit-msg +1 -0
- data/template-dir/hooks/post-checkout +1 -0
- data/template-dir/hooks/post-commit +1 -0
- data/template-dir/hooks/post-merge +1 -0
- data/template-dir/hooks/post-rewrite +1 -0
- data/template-dir/hooks/pre-commit +1 -0
- data/template-dir/hooks/pre-push +1 -0
- data/template-dir/hooks/pre-rebase +1 -0
- metadata +4 -3
- data/template-dir/hooks/commit-msg +0 -115
- data/template-dir/hooks/post-checkout +0 -115
- data/template-dir/hooks/post-commit +0 -115
- data/template-dir/hooks/post-merge +0 -115
- data/template-dir/hooks/post-rewrite +0 -115
- data/template-dir/hooks/pre-commit +0 -115
- data/template-dir/hooks/pre-push +0 -115
- data/template-dir/hooks/pre-rebase +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d759f39313e391b7f4cde7d1285aa377427b61c0
|
4
|
+
data.tar.gz: 0f173b51656136168ef1957a60fb0f46b0a34df3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a28b868f5cba117a804d704a8a882cd316d1753b648ecfd25a66c0522d3c1cbe4af4d985e2f575213f839626234dec084a536057eb22da0affbac2526e7a1627
|
7
|
+
data.tar.gz: 2a99d4602e9cbe2bb45386b7d30539a9a3a1105d82b7d3616b2ae02df5f0ca1a02f0c7e2d5c81d8686a245ba5776705b057bd33f733c74aac8619888bed2bd14
|
data/config/default.yml
CHANGED
@@ -175,6 +175,13 @@ PreCommit:
|
|
175
175
|
- 'Gemfile.lock'
|
176
176
|
- '*.gemspec'
|
177
177
|
|
178
|
+
BundleOutdated:
|
179
|
+
enabled: false
|
180
|
+
description: 'List installed gems with newer versions available'
|
181
|
+
required_executable: 'bundle'
|
182
|
+
flags: ['outdated', '--strict', '--parseable']
|
183
|
+
install_command: 'gem install bundler'
|
184
|
+
|
178
185
|
CaseConflicts:
|
179
186
|
enabled: true
|
180
187
|
description: 'Check for case-insensitivity conflicts'
|
@@ -307,7 +314,7 @@ PreCommit:
|
|
307
314
|
enabled: false
|
308
315
|
description: 'Analyze with JSCS'
|
309
316
|
required_executable: 'jscs'
|
310
|
-
flags: ['--reporter=inline'
|
317
|
+
flags: ['--reporter=inline']
|
311
318
|
install_command: 'npm install -g jscs'
|
312
319
|
include: '**/*.js'
|
313
320
|
|
@@ -457,6 +464,7 @@ PreCommit:
|
|
457
464
|
- '**/*.gemspec'
|
458
465
|
- '**/*.rake'
|
459
466
|
- '**/*.rb'
|
467
|
+
- '**/*.ru'
|
460
468
|
- '**/Gemfile'
|
461
469
|
- '**/Rakefile'
|
462
470
|
|
@@ -816,6 +824,7 @@ PrePush:
|
|
816
824
|
ProtectedBranches:
|
817
825
|
enabled: false
|
818
826
|
description: 'Check for illegal pushes to protected branches'
|
827
|
+
destructive_only: true
|
819
828
|
branches: ['master']
|
820
829
|
|
821
830
|
RSpec:
|
@@ -4,12 +4,19 @@ module Overcommit::Hook::CommitMsg
|
|
4
4
|
def run
|
5
5
|
return :pass if empty_message?
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
subject = commit_message_lines[0].to_s
|
8
|
+
first_letter = subject.match(/^[[:punct:]]*(.)/)[1]
|
9
|
+
unless special_prefix?(subject) || first_letter =~ /[[:upper:]]/
|
9
10
|
return :warn, 'Subject should start with a capital letter'
|
10
11
|
end
|
11
12
|
|
12
13
|
:pass
|
13
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def special_prefix?(subject)
|
19
|
+
subject =~ /^(fixup|squash)!/
|
20
|
+
end
|
14
21
|
end
|
15
22
|
end
|
@@ -18,7 +18,9 @@ module Overcommit::Hook::CommitMsg
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def find_errors_in_subject(subject)
|
21
|
-
max_subject_width =
|
21
|
+
max_subject_width =
|
22
|
+
config['max_subject_width'] +
|
23
|
+
special_prefix_length(subject)
|
22
24
|
return unless subject.length > max_subject_width
|
23
25
|
|
24
26
|
@errors << "Please keep the subject <= #{max_subject_width} characters"
|
@@ -36,5 +38,9 @@ module Overcommit::Hook::CommitMsg
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
41
|
+
|
42
|
+
def special_prefix_length(subject)
|
43
|
+
subject.match(/^(fixup|squash)! /) { |match| match[0].length } || 0
|
44
|
+
end
|
39
45
|
end
|
40
46
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Overcommit::Hook::PreCommit
|
2
|
+
# Check if any gems in Gemfile.lock have newer versions, unless the
|
3
|
+
# Gemfile.lock is ignored by Git.
|
4
|
+
#
|
5
|
+
# @see http://bundler.io/bundle_outdated.html
|
6
|
+
class BundleOutdated < Base
|
7
|
+
LOCK_FILE = 'Gemfile.lock'.freeze
|
8
|
+
|
9
|
+
def run
|
10
|
+
# Ignore if Gemfile.lock is not tracked by git
|
11
|
+
ignored_files = execute(%w[git ls-files -o -i --exclude-standard]).stdout.split("\n")
|
12
|
+
return :pass if ignored_files.include?(LOCK_FILE)
|
13
|
+
|
14
|
+
result = execute(command)
|
15
|
+
warn_msgs = result.stdout.split("\n").
|
16
|
+
reject { |str| str.strip.empty? }.
|
17
|
+
reject { |str| (str.strip =~ /^(\[|\()?warning|deprecation/i) }
|
18
|
+
warnings = warn_msgs.map { |msg| Overcommit::Hook::Message.new(:warning, nil, nil, msg) }
|
19
|
+
|
20
|
+
warnings.empty? ? :pass : warnings
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -23,6 +23,7 @@ module Overcommit::Hook::PreCommit
|
|
23
23
|
|
24
24
|
def parse_messages(output)
|
25
25
|
output.scan(MESSAGE_REGEX).map do |file, line, type, msg|
|
26
|
+
line = line.to_i
|
26
27
|
type = MESSAGE_TYPE_CATEGORIZER.call(type)
|
27
28
|
text = "#{file}:#{line}:#{type} #{msg}"
|
28
29
|
Overcommit::Hook::Message.new(type, file, line, text)
|
@@ -8,8 +8,11 @@ module Overcommit::Hook::PreCommit
|
|
8
8
|
# somewhere else. Example:
|
9
9
|
#
|
10
10
|
# EsLint:
|
11
|
+
# required_executable: 'npm'
|
11
12
|
# enabled: true
|
12
|
-
# command: ['npm', 'run', 'lint']
|
13
|
+
# command: ['npm', 'run', 'lint', '--', '-f', 'compact']
|
14
|
+
#
|
15
|
+
# Note: This hook supports only compact format.
|
13
16
|
#
|
14
17
|
# @see http://eslint.org/
|
15
18
|
class EsLint < Base
|
@@ -15,7 +15,7 @@ module Overcommit::Hook::PrePush
|
|
15
15
|
|
16
16
|
def illegal_pushes
|
17
17
|
@illegal_pushes ||= pushed_refs.select do |pushed_ref|
|
18
|
-
protected?(pushed_ref.remote_ref) && pushed_ref
|
18
|
+
protected?(pushed_ref.remote_ref) && allow_non_destructive?(pushed_ref)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -30,5 +30,17 @@ module Overcommit::Hook::PrePush
|
|
30
30
|
@protected_branch_patterns ||= Array(config['branches']).
|
31
31
|
concat(Array(config['branch_patterns']))
|
32
32
|
end
|
33
|
+
|
34
|
+
def destructive_only?
|
35
|
+
config['destructive_only'].nil? || config['destructive_only']
|
36
|
+
end
|
37
|
+
|
38
|
+
def allow_non_destructive?(ref)
|
39
|
+
if destructive_only?
|
40
|
+
ref.destructive?
|
41
|
+
else
|
42
|
+
true
|
43
|
+
end
|
44
|
+
end
|
33
45
|
end
|
34
46
|
end
|
data/lib/overcommit/utils.rb
CHANGED
@@ -220,7 +220,8 @@ module Overcommit
|
|
220
220
|
if Overcommit::OS.windows?
|
221
221
|
require 'win32ole'
|
222
222
|
result = WIN32OLE.connect('winmgmts://').ExecQuery(
|
223
|
-
'select NumberOfLogicalProcessors from Win32_Processor'
|
223
|
+
'select NumberOfLogicalProcessors from Win32_Processor'
|
224
|
+
)
|
224
225
|
result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
|
225
226
|
elsif File.readable?('/proc/cpuinfo')
|
226
227
|
IO.read('/proc/cpuinfo').scan(/^processor/).size
|
@@ -284,9 +285,10 @@ module Overcommit
|
|
284
285
|
# @param pattern [String]
|
285
286
|
# @param path [String]
|
286
287
|
def matches_path?(pattern, path)
|
287
|
-
File.fnmatch?(
|
288
|
-
|
289
|
-
|
288
|
+
File.fnmatch?(
|
289
|
+
pattern, path,
|
290
|
+
File::FNM_PATHNAME | # Wildcard doesn't match separator
|
291
|
+
File::FNM_DOTMATCH # Wildcards match dotfiles
|
290
292
|
)
|
291
293
|
end
|
292
294
|
|
data/lib/overcommit/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
overcommit-hook
|
@@ -0,0 +1 @@
|
|
1
|
+
overcommit-hook
|
@@ -0,0 +1 @@
|
|
1
|
+
overcommit-hook
|
@@ -0,0 +1 @@
|
|
1
|
+
overcommit-hook
|
@@ -0,0 +1 @@
|
|
1
|
+
overcommit-hook
|
@@ -0,0 +1 @@
|
|
1
|
+
overcommit-hook
|
@@ -0,0 +1 @@
|
|
1
|
+
overcommit-hook
|
@@ -0,0 +1 @@
|
|
1
|
+
overcommit-hook
|
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.
|
4
|
+
version: 0.34.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brigade Engineering
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: childprocess
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- lib/overcommit/hook/pre_commit/brakeman.rb
|
107
107
|
- lib/overcommit/hook/pre_commit/broken_symlinks.rb
|
108
108
|
- lib/overcommit/hook/pre_commit/bundle_check.rb
|
109
|
+
- lib/overcommit/hook/pre_commit/bundle_outdated.rb
|
109
110
|
- lib/overcommit/hook/pre_commit/case_conflicts.rb
|
110
111
|
- lib/overcommit/hook/pre_commit/chamber_security.rb
|
111
112
|
- lib/overcommit/hook/pre_commit/coffee_lint.rb
|
@@ -228,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
228
229
|
version: '0'
|
229
230
|
requirements: []
|
230
231
|
rubyforge_project:
|
231
|
-
rubygems_version: 2.
|
232
|
+
rubygems_version: 2.5.1
|
232
233
|
signing_key:
|
233
234
|
specification_version: 4
|
234
235
|
summary: Git hook manager
|
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
4
|
-
# in all of your git hooks being symlinked to this file, allowing the framework
|
5
|
-
# to manage your hooks for you.
|
6
|
-
|
7
|
-
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
8
|
-
# Note that this will be overridden when Overcommit is loaded, since the
|
9
|
-
# InterruptHandler will redefine the trap at that time.
|
10
|
-
Signal.trap('INT') do
|
11
|
-
puts 'Hook run interrupted'
|
12
|
-
exit 130
|
13
|
-
end
|
14
|
-
|
15
|
-
# Allow hooks to be disabled via environment variable so git commands can be run
|
16
|
-
# in scripts without Overcommit running hooks
|
17
|
-
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
hook_type = File.basename($0)
|
22
|
-
if hook_type == 'overcommit-hook'
|
23
|
-
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
24
|
-
"by each hook in a repository's .git/hooks directory."
|
25
|
-
exit 64 # EX_USAGE
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if Overcommit should invoke a Bundler context for loading gems
|
29
|
-
require 'yaml'
|
30
|
-
# rubocop:disable Style/RescueModifier
|
31
|
-
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
32
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
33
|
-
require 'bundler'
|
34
|
-
|
35
|
-
begin
|
36
|
-
Bundler.setup
|
37
|
-
rescue Bundler::BundlerError => ex
|
38
|
-
puts "Problem loading '#{gemfile}': #{ex.message}"
|
39
|
-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
40
|
-
exit 78 # EX_CONFIG
|
41
|
-
end
|
42
|
-
end
|
43
|
-
# rubocop:enable Style/RescueModifier
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'overcommit'
|
47
|
-
rescue LoadError
|
48
|
-
if gemfile
|
49
|
-
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
50
|
-
'configuration but have not added the `overcommit` gem to ' \
|
51
|
-
"#{gemfile}."
|
52
|
-
else
|
53
|
-
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
54
|
-
"`overcommit` gem is not installed.\n" \
|
55
|
-
'Install it with `gem install overcommit`.'
|
56
|
-
end
|
57
|
-
|
58
|
-
exit 64 # EX_USAGE
|
59
|
-
end
|
60
|
-
|
61
|
-
begin
|
62
|
-
logger = Overcommit::Logger.new(STDOUT)
|
63
|
-
Overcommit::Utils.log = logger
|
64
|
-
|
65
|
-
# Ensure master hook is up-to-date
|
66
|
-
installer = Overcommit::Installer.new(logger)
|
67
|
-
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
68
|
-
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
69
|
-
end
|
70
|
-
|
71
|
-
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
72
|
-
|
73
|
-
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
|
-
config.apply_environment!(context, ENV)
|
75
|
-
|
76
|
-
printer = Overcommit::Printer.new(config, logger, context)
|
77
|
-
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
|
-
|
79
|
-
status = runner.run
|
80
|
-
|
81
|
-
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
82
|
-
rescue Overcommit::Exceptions::ConfigurationError => error
|
83
|
-
puts error
|
84
|
-
exit 78 # EX_CONFIG
|
85
|
-
rescue Overcommit::Exceptions::HookContextLoadError => error
|
86
|
-
puts error
|
87
|
-
puts 'Are you running an old version of Overcommit?'
|
88
|
-
exit 69 # EX_UNAVAILABLE
|
89
|
-
rescue Overcommit::Exceptions::HookLoadError,
|
90
|
-
Overcommit::Exceptions::InvalidHookDefinition => error
|
91
|
-
puts error.message
|
92
|
-
puts error.backtrace
|
93
|
-
exit 78 # EX_CONFIG
|
94
|
-
rescue Overcommit::Exceptions::HookSetupFailed,
|
95
|
-
Overcommit::Exceptions::HookCleanupFailed => error
|
96
|
-
puts error.message
|
97
|
-
exit 74 # EX_IOERR
|
98
|
-
rescue Overcommit::Exceptions::HookCancelled
|
99
|
-
puts 'You cancelled the hook run'
|
100
|
-
exit 130 # Ctrl-C cancel
|
101
|
-
rescue Overcommit::Exceptions::InvalidGitRepo => error
|
102
|
-
puts error
|
103
|
-
exit 64 # EX_USAGE
|
104
|
-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => error
|
105
|
-
puts error
|
106
|
-
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
107
|
-
exit 1
|
108
|
-
rescue Overcommit::Exceptions::InvalidHookSignature
|
109
|
-
exit 1
|
110
|
-
rescue => error
|
111
|
-
puts error.message
|
112
|
-
puts error.backtrace
|
113
|
-
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
114
|
-
exit 70 # EX_SOFTWARE
|
115
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
4
|
-
# in all of your git hooks being symlinked to this file, allowing the framework
|
5
|
-
# to manage your hooks for you.
|
6
|
-
|
7
|
-
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
8
|
-
# Note that this will be overridden when Overcommit is loaded, since the
|
9
|
-
# InterruptHandler will redefine the trap at that time.
|
10
|
-
Signal.trap('INT') do
|
11
|
-
puts 'Hook run interrupted'
|
12
|
-
exit 130
|
13
|
-
end
|
14
|
-
|
15
|
-
# Allow hooks to be disabled via environment variable so git commands can be run
|
16
|
-
# in scripts without Overcommit running hooks
|
17
|
-
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
hook_type = File.basename($0)
|
22
|
-
if hook_type == 'overcommit-hook'
|
23
|
-
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
24
|
-
"by each hook in a repository's .git/hooks directory."
|
25
|
-
exit 64 # EX_USAGE
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if Overcommit should invoke a Bundler context for loading gems
|
29
|
-
require 'yaml'
|
30
|
-
# rubocop:disable Style/RescueModifier
|
31
|
-
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
32
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
33
|
-
require 'bundler'
|
34
|
-
|
35
|
-
begin
|
36
|
-
Bundler.setup
|
37
|
-
rescue Bundler::BundlerError => ex
|
38
|
-
puts "Problem loading '#{gemfile}': #{ex.message}"
|
39
|
-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
40
|
-
exit 78 # EX_CONFIG
|
41
|
-
end
|
42
|
-
end
|
43
|
-
# rubocop:enable Style/RescueModifier
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'overcommit'
|
47
|
-
rescue LoadError
|
48
|
-
if gemfile
|
49
|
-
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
50
|
-
'configuration but have not added the `overcommit` gem to ' \
|
51
|
-
"#{gemfile}."
|
52
|
-
else
|
53
|
-
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
54
|
-
"`overcommit` gem is not installed.\n" \
|
55
|
-
'Install it with `gem install overcommit`.'
|
56
|
-
end
|
57
|
-
|
58
|
-
exit 64 # EX_USAGE
|
59
|
-
end
|
60
|
-
|
61
|
-
begin
|
62
|
-
logger = Overcommit::Logger.new(STDOUT)
|
63
|
-
Overcommit::Utils.log = logger
|
64
|
-
|
65
|
-
# Ensure master hook is up-to-date
|
66
|
-
installer = Overcommit::Installer.new(logger)
|
67
|
-
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
68
|
-
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
69
|
-
end
|
70
|
-
|
71
|
-
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
72
|
-
|
73
|
-
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
|
-
config.apply_environment!(context, ENV)
|
75
|
-
|
76
|
-
printer = Overcommit::Printer.new(config, logger, context)
|
77
|
-
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
|
-
|
79
|
-
status = runner.run
|
80
|
-
|
81
|
-
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
82
|
-
rescue Overcommit::Exceptions::ConfigurationError => error
|
83
|
-
puts error
|
84
|
-
exit 78 # EX_CONFIG
|
85
|
-
rescue Overcommit::Exceptions::HookContextLoadError => error
|
86
|
-
puts error
|
87
|
-
puts 'Are you running an old version of Overcommit?'
|
88
|
-
exit 69 # EX_UNAVAILABLE
|
89
|
-
rescue Overcommit::Exceptions::HookLoadError,
|
90
|
-
Overcommit::Exceptions::InvalidHookDefinition => error
|
91
|
-
puts error.message
|
92
|
-
puts error.backtrace
|
93
|
-
exit 78 # EX_CONFIG
|
94
|
-
rescue Overcommit::Exceptions::HookSetupFailed,
|
95
|
-
Overcommit::Exceptions::HookCleanupFailed => error
|
96
|
-
puts error.message
|
97
|
-
exit 74 # EX_IOERR
|
98
|
-
rescue Overcommit::Exceptions::HookCancelled
|
99
|
-
puts 'You cancelled the hook run'
|
100
|
-
exit 130 # Ctrl-C cancel
|
101
|
-
rescue Overcommit::Exceptions::InvalidGitRepo => error
|
102
|
-
puts error
|
103
|
-
exit 64 # EX_USAGE
|
104
|
-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => error
|
105
|
-
puts error
|
106
|
-
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
107
|
-
exit 1
|
108
|
-
rescue Overcommit::Exceptions::InvalidHookSignature
|
109
|
-
exit 1
|
110
|
-
rescue => error
|
111
|
-
puts error.message
|
112
|
-
puts error.backtrace
|
113
|
-
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
114
|
-
exit 70 # EX_SOFTWARE
|
115
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
4
|
-
# in all of your git hooks being symlinked to this file, allowing the framework
|
5
|
-
# to manage your hooks for you.
|
6
|
-
|
7
|
-
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
8
|
-
# Note that this will be overridden when Overcommit is loaded, since the
|
9
|
-
# InterruptHandler will redefine the trap at that time.
|
10
|
-
Signal.trap('INT') do
|
11
|
-
puts 'Hook run interrupted'
|
12
|
-
exit 130
|
13
|
-
end
|
14
|
-
|
15
|
-
# Allow hooks to be disabled via environment variable so git commands can be run
|
16
|
-
# in scripts without Overcommit running hooks
|
17
|
-
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
hook_type = File.basename($0)
|
22
|
-
if hook_type == 'overcommit-hook'
|
23
|
-
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
24
|
-
"by each hook in a repository's .git/hooks directory."
|
25
|
-
exit 64 # EX_USAGE
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if Overcommit should invoke a Bundler context for loading gems
|
29
|
-
require 'yaml'
|
30
|
-
# rubocop:disable Style/RescueModifier
|
31
|
-
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
32
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
33
|
-
require 'bundler'
|
34
|
-
|
35
|
-
begin
|
36
|
-
Bundler.setup
|
37
|
-
rescue Bundler::BundlerError => ex
|
38
|
-
puts "Problem loading '#{gemfile}': #{ex.message}"
|
39
|
-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
40
|
-
exit 78 # EX_CONFIG
|
41
|
-
end
|
42
|
-
end
|
43
|
-
# rubocop:enable Style/RescueModifier
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'overcommit'
|
47
|
-
rescue LoadError
|
48
|
-
if gemfile
|
49
|
-
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
50
|
-
'configuration but have not added the `overcommit` gem to ' \
|
51
|
-
"#{gemfile}."
|
52
|
-
else
|
53
|
-
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
54
|
-
"`overcommit` gem is not installed.\n" \
|
55
|
-
'Install it with `gem install overcommit`.'
|
56
|
-
end
|
57
|
-
|
58
|
-
exit 64 # EX_USAGE
|
59
|
-
end
|
60
|
-
|
61
|
-
begin
|
62
|
-
logger = Overcommit::Logger.new(STDOUT)
|
63
|
-
Overcommit::Utils.log = logger
|
64
|
-
|
65
|
-
# Ensure master hook is up-to-date
|
66
|
-
installer = Overcommit::Installer.new(logger)
|
67
|
-
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
68
|
-
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
69
|
-
end
|
70
|
-
|
71
|
-
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
72
|
-
|
73
|
-
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
|
-
config.apply_environment!(context, ENV)
|
75
|
-
|
76
|
-
printer = Overcommit::Printer.new(config, logger, context)
|
77
|
-
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
|
-
|
79
|
-
status = runner.run
|
80
|
-
|
81
|
-
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
82
|
-
rescue Overcommit::Exceptions::ConfigurationError => error
|
83
|
-
puts error
|
84
|
-
exit 78 # EX_CONFIG
|
85
|
-
rescue Overcommit::Exceptions::HookContextLoadError => error
|
86
|
-
puts error
|
87
|
-
puts 'Are you running an old version of Overcommit?'
|
88
|
-
exit 69 # EX_UNAVAILABLE
|
89
|
-
rescue Overcommit::Exceptions::HookLoadError,
|
90
|
-
Overcommit::Exceptions::InvalidHookDefinition => error
|
91
|
-
puts error.message
|
92
|
-
puts error.backtrace
|
93
|
-
exit 78 # EX_CONFIG
|
94
|
-
rescue Overcommit::Exceptions::HookSetupFailed,
|
95
|
-
Overcommit::Exceptions::HookCleanupFailed => error
|
96
|
-
puts error.message
|
97
|
-
exit 74 # EX_IOERR
|
98
|
-
rescue Overcommit::Exceptions::HookCancelled
|
99
|
-
puts 'You cancelled the hook run'
|
100
|
-
exit 130 # Ctrl-C cancel
|
101
|
-
rescue Overcommit::Exceptions::InvalidGitRepo => error
|
102
|
-
puts error
|
103
|
-
exit 64 # EX_USAGE
|
104
|
-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => error
|
105
|
-
puts error
|
106
|
-
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
107
|
-
exit 1
|
108
|
-
rescue Overcommit::Exceptions::InvalidHookSignature
|
109
|
-
exit 1
|
110
|
-
rescue => error
|
111
|
-
puts error.message
|
112
|
-
puts error.backtrace
|
113
|
-
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
114
|
-
exit 70 # EX_SOFTWARE
|
115
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
4
|
-
# in all of your git hooks being symlinked to this file, allowing the framework
|
5
|
-
# to manage your hooks for you.
|
6
|
-
|
7
|
-
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
8
|
-
# Note that this will be overridden when Overcommit is loaded, since the
|
9
|
-
# InterruptHandler will redefine the trap at that time.
|
10
|
-
Signal.trap('INT') do
|
11
|
-
puts 'Hook run interrupted'
|
12
|
-
exit 130
|
13
|
-
end
|
14
|
-
|
15
|
-
# Allow hooks to be disabled via environment variable so git commands can be run
|
16
|
-
# in scripts without Overcommit running hooks
|
17
|
-
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
hook_type = File.basename($0)
|
22
|
-
if hook_type == 'overcommit-hook'
|
23
|
-
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
24
|
-
"by each hook in a repository's .git/hooks directory."
|
25
|
-
exit 64 # EX_USAGE
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if Overcommit should invoke a Bundler context for loading gems
|
29
|
-
require 'yaml'
|
30
|
-
# rubocop:disable Style/RescueModifier
|
31
|
-
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
32
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
33
|
-
require 'bundler'
|
34
|
-
|
35
|
-
begin
|
36
|
-
Bundler.setup
|
37
|
-
rescue Bundler::BundlerError => ex
|
38
|
-
puts "Problem loading '#{gemfile}': #{ex.message}"
|
39
|
-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
40
|
-
exit 78 # EX_CONFIG
|
41
|
-
end
|
42
|
-
end
|
43
|
-
# rubocop:enable Style/RescueModifier
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'overcommit'
|
47
|
-
rescue LoadError
|
48
|
-
if gemfile
|
49
|
-
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
50
|
-
'configuration but have not added the `overcommit` gem to ' \
|
51
|
-
"#{gemfile}."
|
52
|
-
else
|
53
|
-
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
54
|
-
"`overcommit` gem is not installed.\n" \
|
55
|
-
'Install it with `gem install overcommit`.'
|
56
|
-
end
|
57
|
-
|
58
|
-
exit 64 # EX_USAGE
|
59
|
-
end
|
60
|
-
|
61
|
-
begin
|
62
|
-
logger = Overcommit::Logger.new(STDOUT)
|
63
|
-
Overcommit::Utils.log = logger
|
64
|
-
|
65
|
-
# Ensure master hook is up-to-date
|
66
|
-
installer = Overcommit::Installer.new(logger)
|
67
|
-
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
68
|
-
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
69
|
-
end
|
70
|
-
|
71
|
-
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
72
|
-
|
73
|
-
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
|
-
config.apply_environment!(context, ENV)
|
75
|
-
|
76
|
-
printer = Overcommit::Printer.new(config, logger, context)
|
77
|
-
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
|
-
|
79
|
-
status = runner.run
|
80
|
-
|
81
|
-
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
82
|
-
rescue Overcommit::Exceptions::ConfigurationError => error
|
83
|
-
puts error
|
84
|
-
exit 78 # EX_CONFIG
|
85
|
-
rescue Overcommit::Exceptions::HookContextLoadError => error
|
86
|
-
puts error
|
87
|
-
puts 'Are you running an old version of Overcommit?'
|
88
|
-
exit 69 # EX_UNAVAILABLE
|
89
|
-
rescue Overcommit::Exceptions::HookLoadError,
|
90
|
-
Overcommit::Exceptions::InvalidHookDefinition => error
|
91
|
-
puts error.message
|
92
|
-
puts error.backtrace
|
93
|
-
exit 78 # EX_CONFIG
|
94
|
-
rescue Overcommit::Exceptions::HookSetupFailed,
|
95
|
-
Overcommit::Exceptions::HookCleanupFailed => error
|
96
|
-
puts error.message
|
97
|
-
exit 74 # EX_IOERR
|
98
|
-
rescue Overcommit::Exceptions::HookCancelled
|
99
|
-
puts 'You cancelled the hook run'
|
100
|
-
exit 130 # Ctrl-C cancel
|
101
|
-
rescue Overcommit::Exceptions::InvalidGitRepo => error
|
102
|
-
puts error
|
103
|
-
exit 64 # EX_USAGE
|
104
|
-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => error
|
105
|
-
puts error
|
106
|
-
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
107
|
-
exit 1
|
108
|
-
rescue Overcommit::Exceptions::InvalidHookSignature
|
109
|
-
exit 1
|
110
|
-
rescue => error
|
111
|
-
puts error.message
|
112
|
-
puts error.backtrace
|
113
|
-
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
114
|
-
exit 70 # EX_SOFTWARE
|
115
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
4
|
-
# in all of your git hooks being symlinked to this file, allowing the framework
|
5
|
-
# to manage your hooks for you.
|
6
|
-
|
7
|
-
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
8
|
-
# Note that this will be overridden when Overcommit is loaded, since the
|
9
|
-
# InterruptHandler will redefine the trap at that time.
|
10
|
-
Signal.trap('INT') do
|
11
|
-
puts 'Hook run interrupted'
|
12
|
-
exit 130
|
13
|
-
end
|
14
|
-
|
15
|
-
# Allow hooks to be disabled via environment variable so git commands can be run
|
16
|
-
# in scripts without Overcommit running hooks
|
17
|
-
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
hook_type = File.basename($0)
|
22
|
-
if hook_type == 'overcommit-hook'
|
23
|
-
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
24
|
-
"by each hook in a repository's .git/hooks directory."
|
25
|
-
exit 64 # EX_USAGE
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if Overcommit should invoke a Bundler context for loading gems
|
29
|
-
require 'yaml'
|
30
|
-
# rubocop:disable Style/RescueModifier
|
31
|
-
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
32
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
33
|
-
require 'bundler'
|
34
|
-
|
35
|
-
begin
|
36
|
-
Bundler.setup
|
37
|
-
rescue Bundler::BundlerError => ex
|
38
|
-
puts "Problem loading '#{gemfile}': #{ex.message}"
|
39
|
-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
40
|
-
exit 78 # EX_CONFIG
|
41
|
-
end
|
42
|
-
end
|
43
|
-
# rubocop:enable Style/RescueModifier
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'overcommit'
|
47
|
-
rescue LoadError
|
48
|
-
if gemfile
|
49
|
-
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
50
|
-
'configuration but have not added the `overcommit` gem to ' \
|
51
|
-
"#{gemfile}."
|
52
|
-
else
|
53
|
-
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
54
|
-
"`overcommit` gem is not installed.\n" \
|
55
|
-
'Install it with `gem install overcommit`.'
|
56
|
-
end
|
57
|
-
|
58
|
-
exit 64 # EX_USAGE
|
59
|
-
end
|
60
|
-
|
61
|
-
begin
|
62
|
-
logger = Overcommit::Logger.new(STDOUT)
|
63
|
-
Overcommit::Utils.log = logger
|
64
|
-
|
65
|
-
# Ensure master hook is up-to-date
|
66
|
-
installer = Overcommit::Installer.new(logger)
|
67
|
-
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
68
|
-
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
69
|
-
end
|
70
|
-
|
71
|
-
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
72
|
-
|
73
|
-
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
|
-
config.apply_environment!(context, ENV)
|
75
|
-
|
76
|
-
printer = Overcommit::Printer.new(config, logger, context)
|
77
|
-
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
|
-
|
79
|
-
status = runner.run
|
80
|
-
|
81
|
-
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
82
|
-
rescue Overcommit::Exceptions::ConfigurationError => error
|
83
|
-
puts error
|
84
|
-
exit 78 # EX_CONFIG
|
85
|
-
rescue Overcommit::Exceptions::HookContextLoadError => error
|
86
|
-
puts error
|
87
|
-
puts 'Are you running an old version of Overcommit?'
|
88
|
-
exit 69 # EX_UNAVAILABLE
|
89
|
-
rescue Overcommit::Exceptions::HookLoadError,
|
90
|
-
Overcommit::Exceptions::InvalidHookDefinition => error
|
91
|
-
puts error.message
|
92
|
-
puts error.backtrace
|
93
|
-
exit 78 # EX_CONFIG
|
94
|
-
rescue Overcommit::Exceptions::HookSetupFailed,
|
95
|
-
Overcommit::Exceptions::HookCleanupFailed => error
|
96
|
-
puts error.message
|
97
|
-
exit 74 # EX_IOERR
|
98
|
-
rescue Overcommit::Exceptions::HookCancelled
|
99
|
-
puts 'You cancelled the hook run'
|
100
|
-
exit 130 # Ctrl-C cancel
|
101
|
-
rescue Overcommit::Exceptions::InvalidGitRepo => error
|
102
|
-
puts error
|
103
|
-
exit 64 # EX_USAGE
|
104
|
-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => error
|
105
|
-
puts error
|
106
|
-
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
107
|
-
exit 1
|
108
|
-
rescue Overcommit::Exceptions::InvalidHookSignature
|
109
|
-
exit 1
|
110
|
-
rescue => error
|
111
|
-
puts error.message
|
112
|
-
puts error.backtrace
|
113
|
-
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
114
|
-
exit 70 # EX_SOFTWARE
|
115
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
4
|
-
# in all of your git hooks being symlinked to this file, allowing the framework
|
5
|
-
# to manage your hooks for you.
|
6
|
-
|
7
|
-
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
8
|
-
# Note that this will be overridden when Overcommit is loaded, since the
|
9
|
-
# InterruptHandler will redefine the trap at that time.
|
10
|
-
Signal.trap('INT') do
|
11
|
-
puts 'Hook run interrupted'
|
12
|
-
exit 130
|
13
|
-
end
|
14
|
-
|
15
|
-
# Allow hooks to be disabled via environment variable so git commands can be run
|
16
|
-
# in scripts without Overcommit running hooks
|
17
|
-
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
hook_type = File.basename($0)
|
22
|
-
if hook_type == 'overcommit-hook'
|
23
|
-
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
24
|
-
"by each hook in a repository's .git/hooks directory."
|
25
|
-
exit 64 # EX_USAGE
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if Overcommit should invoke a Bundler context for loading gems
|
29
|
-
require 'yaml'
|
30
|
-
# rubocop:disable Style/RescueModifier
|
31
|
-
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
32
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
33
|
-
require 'bundler'
|
34
|
-
|
35
|
-
begin
|
36
|
-
Bundler.setup
|
37
|
-
rescue Bundler::BundlerError => ex
|
38
|
-
puts "Problem loading '#{gemfile}': #{ex.message}"
|
39
|
-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
40
|
-
exit 78 # EX_CONFIG
|
41
|
-
end
|
42
|
-
end
|
43
|
-
# rubocop:enable Style/RescueModifier
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'overcommit'
|
47
|
-
rescue LoadError
|
48
|
-
if gemfile
|
49
|
-
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
50
|
-
'configuration but have not added the `overcommit` gem to ' \
|
51
|
-
"#{gemfile}."
|
52
|
-
else
|
53
|
-
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
54
|
-
"`overcommit` gem is not installed.\n" \
|
55
|
-
'Install it with `gem install overcommit`.'
|
56
|
-
end
|
57
|
-
|
58
|
-
exit 64 # EX_USAGE
|
59
|
-
end
|
60
|
-
|
61
|
-
begin
|
62
|
-
logger = Overcommit::Logger.new(STDOUT)
|
63
|
-
Overcommit::Utils.log = logger
|
64
|
-
|
65
|
-
# Ensure master hook is up-to-date
|
66
|
-
installer = Overcommit::Installer.new(logger)
|
67
|
-
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
68
|
-
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
69
|
-
end
|
70
|
-
|
71
|
-
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
72
|
-
|
73
|
-
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
|
-
config.apply_environment!(context, ENV)
|
75
|
-
|
76
|
-
printer = Overcommit::Printer.new(config, logger, context)
|
77
|
-
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
|
-
|
79
|
-
status = runner.run
|
80
|
-
|
81
|
-
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
82
|
-
rescue Overcommit::Exceptions::ConfigurationError => error
|
83
|
-
puts error
|
84
|
-
exit 78 # EX_CONFIG
|
85
|
-
rescue Overcommit::Exceptions::HookContextLoadError => error
|
86
|
-
puts error
|
87
|
-
puts 'Are you running an old version of Overcommit?'
|
88
|
-
exit 69 # EX_UNAVAILABLE
|
89
|
-
rescue Overcommit::Exceptions::HookLoadError,
|
90
|
-
Overcommit::Exceptions::InvalidHookDefinition => error
|
91
|
-
puts error.message
|
92
|
-
puts error.backtrace
|
93
|
-
exit 78 # EX_CONFIG
|
94
|
-
rescue Overcommit::Exceptions::HookSetupFailed,
|
95
|
-
Overcommit::Exceptions::HookCleanupFailed => error
|
96
|
-
puts error.message
|
97
|
-
exit 74 # EX_IOERR
|
98
|
-
rescue Overcommit::Exceptions::HookCancelled
|
99
|
-
puts 'You cancelled the hook run'
|
100
|
-
exit 130 # Ctrl-C cancel
|
101
|
-
rescue Overcommit::Exceptions::InvalidGitRepo => error
|
102
|
-
puts error
|
103
|
-
exit 64 # EX_USAGE
|
104
|
-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => error
|
105
|
-
puts error
|
106
|
-
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
107
|
-
exit 1
|
108
|
-
rescue Overcommit::Exceptions::InvalidHookSignature
|
109
|
-
exit 1
|
110
|
-
rescue => error
|
111
|
-
puts error.message
|
112
|
-
puts error.backtrace
|
113
|
-
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
114
|
-
exit 70 # EX_SOFTWARE
|
115
|
-
end
|
data/template-dir/hooks/pre-push
DELETED
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
4
|
-
# in all of your git hooks being symlinked to this file, allowing the framework
|
5
|
-
# to manage your hooks for you.
|
6
|
-
|
7
|
-
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
8
|
-
# Note that this will be overridden when Overcommit is loaded, since the
|
9
|
-
# InterruptHandler will redefine the trap at that time.
|
10
|
-
Signal.trap('INT') do
|
11
|
-
puts 'Hook run interrupted'
|
12
|
-
exit 130
|
13
|
-
end
|
14
|
-
|
15
|
-
# Allow hooks to be disabled via environment variable so git commands can be run
|
16
|
-
# in scripts without Overcommit running hooks
|
17
|
-
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
hook_type = File.basename($0)
|
22
|
-
if hook_type == 'overcommit-hook'
|
23
|
-
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
24
|
-
"by each hook in a repository's .git/hooks directory."
|
25
|
-
exit 64 # EX_USAGE
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if Overcommit should invoke a Bundler context for loading gems
|
29
|
-
require 'yaml'
|
30
|
-
# rubocop:disable Style/RescueModifier
|
31
|
-
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
32
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
33
|
-
require 'bundler'
|
34
|
-
|
35
|
-
begin
|
36
|
-
Bundler.setup
|
37
|
-
rescue Bundler::BundlerError => ex
|
38
|
-
puts "Problem loading '#{gemfile}': #{ex.message}"
|
39
|
-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
40
|
-
exit 78 # EX_CONFIG
|
41
|
-
end
|
42
|
-
end
|
43
|
-
# rubocop:enable Style/RescueModifier
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'overcommit'
|
47
|
-
rescue LoadError
|
48
|
-
if gemfile
|
49
|
-
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
50
|
-
'configuration but have not added the `overcommit` gem to ' \
|
51
|
-
"#{gemfile}."
|
52
|
-
else
|
53
|
-
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
54
|
-
"`overcommit` gem is not installed.\n" \
|
55
|
-
'Install it with `gem install overcommit`.'
|
56
|
-
end
|
57
|
-
|
58
|
-
exit 64 # EX_USAGE
|
59
|
-
end
|
60
|
-
|
61
|
-
begin
|
62
|
-
logger = Overcommit::Logger.new(STDOUT)
|
63
|
-
Overcommit::Utils.log = logger
|
64
|
-
|
65
|
-
# Ensure master hook is up-to-date
|
66
|
-
installer = Overcommit::Installer.new(logger)
|
67
|
-
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
68
|
-
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
69
|
-
end
|
70
|
-
|
71
|
-
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
72
|
-
|
73
|
-
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
|
-
config.apply_environment!(context, ENV)
|
75
|
-
|
76
|
-
printer = Overcommit::Printer.new(config, logger, context)
|
77
|
-
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
|
-
|
79
|
-
status = runner.run
|
80
|
-
|
81
|
-
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
82
|
-
rescue Overcommit::Exceptions::ConfigurationError => error
|
83
|
-
puts error
|
84
|
-
exit 78 # EX_CONFIG
|
85
|
-
rescue Overcommit::Exceptions::HookContextLoadError => error
|
86
|
-
puts error
|
87
|
-
puts 'Are you running an old version of Overcommit?'
|
88
|
-
exit 69 # EX_UNAVAILABLE
|
89
|
-
rescue Overcommit::Exceptions::HookLoadError,
|
90
|
-
Overcommit::Exceptions::InvalidHookDefinition => error
|
91
|
-
puts error.message
|
92
|
-
puts error.backtrace
|
93
|
-
exit 78 # EX_CONFIG
|
94
|
-
rescue Overcommit::Exceptions::HookSetupFailed,
|
95
|
-
Overcommit::Exceptions::HookCleanupFailed => error
|
96
|
-
puts error.message
|
97
|
-
exit 74 # EX_IOERR
|
98
|
-
rescue Overcommit::Exceptions::HookCancelled
|
99
|
-
puts 'You cancelled the hook run'
|
100
|
-
exit 130 # Ctrl-C cancel
|
101
|
-
rescue Overcommit::Exceptions::InvalidGitRepo => error
|
102
|
-
puts error
|
103
|
-
exit 64 # EX_USAGE
|
104
|
-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => error
|
105
|
-
puts error
|
106
|
-
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
107
|
-
exit 1
|
108
|
-
rescue Overcommit::Exceptions::InvalidHookSignature
|
109
|
-
exit 1
|
110
|
-
rescue => error
|
111
|
-
puts error.message
|
112
|
-
puts error.backtrace
|
113
|
-
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
114
|
-
exit 70 # EX_SOFTWARE
|
115
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Entrypoint for Overcommit hook integration. Installing Overcommit will result
|
4
|
-
# in all of your git hooks being symlinked to this file, allowing the framework
|
5
|
-
# to manage your hooks for you.
|
6
|
-
|
7
|
-
# Prevent a Ruby stack trace from appearing when we interrupt the hook.
|
8
|
-
# Note that this will be overridden when Overcommit is loaded, since the
|
9
|
-
# InterruptHandler will redefine the trap at that time.
|
10
|
-
Signal.trap('INT') do
|
11
|
-
puts 'Hook run interrupted'
|
12
|
-
exit 130
|
13
|
-
end
|
14
|
-
|
15
|
-
# Allow hooks to be disabled via environment variable so git commands can be run
|
16
|
-
# in scripts without Overcommit running hooks
|
17
|
-
if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
|
21
|
-
hook_type = File.basename($0)
|
22
|
-
if hook_type == 'overcommit-hook'
|
23
|
-
puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \
|
24
|
-
"by each hook in a repository's .git/hooks directory."
|
25
|
-
exit 64 # EX_USAGE
|
26
|
-
end
|
27
|
-
|
28
|
-
# Check if Overcommit should invoke a Bundler context for loading gems
|
29
|
-
require 'yaml'
|
30
|
-
# rubocop:disable Style/RescueModifier
|
31
|
-
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
32
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
33
|
-
require 'bundler'
|
34
|
-
|
35
|
-
begin
|
36
|
-
Bundler.setup
|
37
|
-
rescue Bundler::BundlerError => ex
|
38
|
-
puts "Problem loading '#{gemfile}': #{ex.message}"
|
39
|
-
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
40
|
-
exit 78 # EX_CONFIG
|
41
|
-
end
|
42
|
-
end
|
43
|
-
# rubocop:enable Style/RescueModifier
|
44
|
-
|
45
|
-
begin
|
46
|
-
require 'overcommit'
|
47
|
-
rescue LoadError
|
48
|
-
if gemfile
|
49
|
-
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
50
|
-
'configuration but have not added the `overcommit` gem to ' \
|
51
|
-
"#{gemfile}."
|
52
|
-
else
|
53
|
-
puts 'This repository contains hooks installed by Overcommit, but the ' \
|
54
|
-
"`overcommit` gem is not installed.\n" \
|
55
|
-
'Install it with `gem install overcommit`.'
|
56
|
-
end
|
57
|
-
|
58
|
-
exit 64 # EX_USAGE
|
59
|
-
end
|
60
|
-
|
61
|
-
begin
|
62
|
-
logger = Overcommit::Logger.new(STDOUT)
|
63
|
-
Overcommit::Utils.log = logger
|
64
|
-
|
65
|
-
# Ensure master hook is up-to-date
|
66
|
-
installer = Overcommit::Installer.new(logger)
|
67
|
-
if installer.run(Overcommit::Utils.repo_root, action: :update)
|
68
|
-
exec($0, *ARGV) # Execute the updated hook with all original arguments
|
69
|
-
end
|
70
|
-
|
71
|
-
config = Overcommit::ConfigurationLoader.new(logger).load_repo_config
|
72
|
-
|
73
|
-
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
|
-
config.apply_environment!(context, ENV)
|
75
|
-
|
76
|
-
printer = Overcommit::Printer.new(config, logger, context)
|
77
|
-
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
|
-
|
79
|
-
status = runner.run
|
80
|
-
|
81
|
-
exit(status ? 0 : 65) # 65 = EX_DATAERR
|
82
|
-
rescue Overcommit::Exceptions::ConfigurationError => error
|
83
|
-
puts error
|
84
|
-
exit 78 # EX_CONFIG
|
85
|
-
rescue Overcommit::Exceptions::HookContextLoadError => error
|
86
|
-
puts error
|
87
|
-
puts 'Are you running an old version of Overcommit?'
|
88
|
-
exit 69 # EX_UNAVAILABLE
|
89
|
-
rescue Overcommit::Exceptions::HookLoadError,
|
90
|
-
Overcommit::Exceptions::InvalidHookDefinition => error
|
91
|
-
puts error.message
|
92
|
-
puts error.backtrace
|
93
|
-
exit 78 # EX_CONFIG
|
94
|
-
rescue Overcommit::Exceptions::HookSetupFailed,
|
95
|
-
Overcommit::Exceptions::HookCleanupFailed => error
|
96
|
-
puts error.message
|
97
|
-
exit 74 # EX_IOERR
|
98
|
-
rescue Overcommit::Exceptions::HookCancelled
|
99
|
-
puts 'You cancelled the hook run'
|
100
|
-
exit 130 # Ctrl-C cancel
|
101
|
-
rescue Overcommit::Exceptions::InvalidGitRepo => error
|
102
|
-
puts error
|
103
|
-
exit 64 # EX_USAGE
|
104
|
-
rescue Overcommit::Exceptions::ConfigurationSignatureChanged => error
|
105
|
-
puts error
|
106
|
-
puts "For more information, see #{Overcommit::REPO_URL}#security"
|
107
|
-
exit 1
|
108
|
-
rescue Overcommit::Exceptions::InvalidHookSignature
|
109
|
-
exit 1
|
110
|
-
rescue => error
|
111
|
-
puts error.message
|
112
|
-
puts error.backtrace
|
113
|
-
puts "Report this bug at #{Overcommit::BUG_REPORT_URL}"
|
114
|
-
exit 70 # EX_SOFTWARE
|
115
|
-
end
|