forked from sds/overcommit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathovercommit
More file actions
executable file
·45 lines (39 loc) · 1.2 KB
/
overcommit
File metadata and controls
executable file
·45 lines (39 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env ruby
# Check if Overcommit should invoke a Bundler context for loading gems
require 'yaml'
# rubocop:disable Style/RescueModifier
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
begin
# We need to temporarily silence STDERR to remove annoying Gem specification
# warnings that ultimately don't matter, e.g.
# https://github.com/rubygems/rubygems/issues/1070
old_stderr = $stderr
begin
$stderr = File.new(File::NULL, 'w')
Bundler.setup
ensure
$stderr = old_stderr
end
rescue Bundler::BundlerError => ex
puts "Problem loading '#{gemfile}': #{ex.message}"
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
exit 78 # EX_CONFIG
end
end
# rubocop:enable Style/RescueModifier
begin
require 'overcommit/cli'
rescue LoadError
if gemfile
puts 'You have specified the `gemfile` option in your Overcommit ' \
'configuration but have not added the `overcommit` gem to ' \
"#{gemfile}."
else
raise
end
exit 64 # EX_USAGE
end
logger = Overcommit::Logger.new(STDOUT)
Overcommit::CLI.new(ARGV, STDIN, logger).run