overcommit 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/overcommit +39 -1
- data/config/default.yml +4 -0
- data/lib/overcommit/cli.rb +1 -1
- data/lib/overcommit/hook/pre_commit/author_email.rb +9 -3
- data/lib/overcommit/hook/pre_commit/author_name.rb +9 -3
- data/lib/overcommit/hook/pre_commit/java_checkstyle.rb +1 -1
- data/lib/overcommit/hook_loader/plugin_hook_loader.rb +1 -1
- data/lib/overcommit/printer.rb +11 -8
- data/lib/overcommit/version.rb +1 -1
- data/template-dir/hooks/commit-msg +1 -1
- data/template-dir/hooks/overcommit-hook +1 -1
- data/template-dir/hooks/post-checkout +1 -1
- data/template-dir/hooks/post-commit +1 -1
- data/template-dir/hooks/post-merge +1 -1
- data/template-dir/hooks/post-rewrite +1 -1
- data/template-dir/hooks/pre-commit +1 -1
- data/template-dir/hooks/pre-push +1 -1
- data/template-dir/hooks/pre-rebase +1 -1
- metadata +2 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82d13816e551875c9d755901cb847f586459cefd
|
4
|
+
data.tar.gz: 582491d7682c80f69a4b931a9fb03bc3e0a63ce9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2affc1f9a55e9db9fd9d5f260ffa347715f4bf9694f244707a3503f0d5eefe1ab8036f27053873ef523a1190e49566bf5bb0b3a7bfef710274501ffe06b7e52a
|
7
|
+
data.tar.gz: c11fc79fcc65a689c852f7fb2428131cb51b6dcef877dbf0ea8e4314bd603a89ab22b10d08dab35223e0c525fe630bf0c88fefef7d4d143e846c47d4a38ba531
|
data/bin/overcommit
CHANGED
@@ -1,6 +1,44 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
# Check if Overcommit should invoke a Bundler context for loading gems
|
4
|
+
require 'yaml'
|
5
|
+
# rubocop:disable Style/RescueModifier
|
6
|
+
if gemfile = YAML.load_file('.overcommit.yml')['gemfile'] rescue nil
|
7
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
8
|
+
require 'bundler'
|
9
|
+
|
10
|
+
begin
|
11
|
+
# We need to temporarily silence STDERR to remove annoying Gem specification
|
12
|
+
# warnings that ultimately don't matter, e.g.
|
13
|
+
# https://github.com/rubygems/rubygems/issues/1070
|
14
|
+
old_stderr = $stderr
|
15
|
+
begin
|
16
|
+
$stderr = File.new(File::NULL, 'w')
|
17
|
+
Bundler.setup
|
18
|
+
ensure
|
19
|
+
$stderr = old_stderr
|
20
|
+
end
|
21
|
+
rescue Bundler::BundlerError => ex
|
22
|
+
puts "Problem loading '#{gemfile}': #{ex.message}"
|
23
|
+
puts "Try running:\nbundle install --gemfile=#{gemfile}" if ex.is_a?(Bundler::GemNotFound)
|
24
|
+
exit 78 # EX_CONFIG
|
25
|
+
end
|
26
|
+
end
|
27
|
+
# rubocop:enable Style/RescueModifier
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'overcommit/cli'
|
31
|
+
rescue LoadError
|
32
|
+
if gemfile
|
33
|
+
puts 'You have specified the `gemfile` option in your Overcommit ' \
|
34
|
+
'configuration but have not added the `overcommit` gem to ' \
|
35
|
+
"#{gemfile}."
|
36
|
+
else
|
37
|
+
raise
|
38
|
+
end
|
39
|
+
|
40
|
+
exit 64 # EX_USAGE
|
41
|
+
end
|
4
42
|
|
5
43
|
logger = Overcommit::Logger.new(STDOUT)
|
6
44
|
|
data/config/default.yml
CHANGED
@@ -39,6 +39,10 @@ gemfile: false
|
|
39
39
|
# to the root of the repository.
|
40
40
|
plugin_directory: '.git-hooks'
|
41
41
|
|
42
|
+
# Whether to hide hook output by default. This results in completely silent hook
|
43
|
+
# runs except in the case of warning or failure.
|
44
|
+
quiet: false
|
45
|
+
|
42
46
|
# Number of hooks that can be run concurrently. Typically this won't need to be
|
43
47
|
# adjusted, but if you know that some of your hooks themselves use multiple
|
44
48
|
# processors you can lower this value accordingly. You can define
|
data/lib/overcommit/cli.rb
CHANGED
@@ -197,7 +197,7 @@ module Overcommit
|
|
197
197
|
context = Overcommit::HookContext.create('run-all', config, @arguments, empty_stdin)
|
198
198
|
config.apply_environment!(context, ENV)
|
199
199
|
|
200
|
-
printer = Overcommit::Printer.new(log, context)
|
200
|
+
printer = Overcommit::Printer.new(config, log, context)
|
201
201
|
runner = Overcommit::HookRunner.new(config, log, context, printer)
|
202
202
|
|
203
203
|
status = runner.run
|
@@ -2,14 +2,20 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Checks the format of an author's email address.
|
3
3
|
class AuthorEmail < Base
|
4
4
|
def run
|
5
|
-
|
6
|
-
|
5
|
+
email =
|
6
|
+
if ENV.key?('GIT_AUTHOR_EMAIL')
|
7
|
+
ENV['GIT_AUTHOR_EMAIL']
|
8
|
+
else
|
9
|
+
result = execute(%w[git config --get user.email])
|
10
|
+
result.stdout.chomp
|
11
|
+
end
|
7
12
|
|
8
13
|
unless email =~ /#{config['pattern']}/
|
9
14
|
return :fail,
|
10
15
|
"Author has an invalid email address: '#{email}'\n" \
|
11
16
|
'Set your email with ' \
|
12
|
-
'`git config --global user.email your_email@example.com`'
|
17
|
+
'`git config --global user.email your_email@example.com` ' \
|
18
|
+
'or via the GIT_AUTHOR_EMAIL environment variable'
|
13
19
|
end
|
14
20
|
|
15
21
|
:pass
|
@@ -2,13 +2,19 @@ module Overcommit::Hook::PreCommit
|
|
2
2
|
# Ensures that a commit author has a name with at least first and last names.
|
3
3
|
class AuthorName < Base
|
4
4
|
def run
|
5
|
-
|
6
|
-
|
5
|
+
name =
|
6
|
+
if ENV.key?('GIT_AUTHOR_NAME')
|
7
|
+
ENV['GIT_AUTHOR_NAME']
|
8
|
+
else
|
9
|
+
result = execute(%w[git config --get user.name])
|
10
|
+
result.stdout.chomp
|
11
|
+
end
|
7
12
|
|
8
13
|
unless name.split(' ').count >= 2
|
9
14
|
return :fail,
|
10
15
|
"Author must have at least first and last name, but was: #{name}.\n" \
|
11
|
-
'Set your name with `git config --global user.name "Your Name"`'
|
16
|
+
'Set your name with `git config --global user.name "Your Name"` ' \
|
17
|
+
'or via the GIT_AUTHOR_NAME environment variable'
|
12
18
|
end
|
13
19
|
|
14
20
|
:pass
|
@@ -3,7 +3,7 @@ module Overcommit::Hook::PreCommit
|
|
3
3
|
#
|
4
4
|
# @see http://checkstyle.sourceforge.net/
|
5
5
|
class JavaCheckstyle < Base
|
6
|
-
MESSAGE_REGEX = /^(?<file>(?:\w:)?[^:]+):(?<line>\d+)/
|
6
|
+
MESSAGE_REGEX = /^(\[[^\]]+\]\s+)?(?<file>(?:\w:)?[^:]+):(?<line>\d+)/
|
7
7
|
|
8
8
|
def run
|
9
9
|
result = execute(command, args: applicable_files)
|
@@ -79,7 +79,7 @@ module Overcommit::HookLoader
|
|
79
79
|
# Implement a simple class that executes the command and returns pass/fail
|
80
80
|
# based on the exit status
|
81
81
|
hook_class = Class.new(hook_base) do
|
82
|
-
def run
|
82
|
+
def run
|
83
83
|
result = @context.execute_hook(command)
|
84
84
|
|
85
85
|
if result.success?
|
data/lib/overcommit/printer.rb
CHANGED
@@ -8,7 +8,8 @@ module Overcommit
|
|
8
8
|
class Printer
|
9
9
|
attr_reader :log
|
10
10
|
|
11
|
-
def initialize(logger, context)
|
11
|
+
def initialize(config, logger, context)
|
12
|
+
@config = config
|
12
13
|
@log = logger
|
13
14
|
@context = context
|
14
15
|
@lock = Monitor.new # Need to use monitor so we can have re-entrant locks
|
@@ -17,7 +18,7 @@ module Overcommit
|
|
17
18
|
|
18
19
|
# Executed at the very beginning of running the collection of hooks.
|
19
20
|
def start_run
|
20
|
-
log.bold "Running #{hook_script_name} hooks"
|
21
|
+
log.bold "Running #{hook_script_name} hooks" unless @config['quiet']
|
21
22
|
end
|
22
23
|
|
23
24
|
def nothing_to_run
|
@@ -36,7 +37,7 @@ module Overcommit
|
|
36
37
|
def end_hook(hook, status, output)
|
37
38
|
# Want to print the header for quiet hooks only if the result wasn't good
|
38
39
|
# so that the user knows what failed
|
39
|
-
print_header(hook) if !hook.quiet? || status != :pass
|
40
|
+
print_header(hook) if (!hook.quiet? && !@config['quiet']) || status != :pass
|
40
41
|
|
41
42
|
print_result(hook, status, output)
|
42
43
|
end
|
@@ -69,9 +70,11 @@ module Overcommit
|
|
69
70
|
|
70
71
|
# Executed when no hooks failed by the end of the run.
|
71
72
|
def run_succeeded
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
unless @config['quiet']
|
74
|
+
log.newline
|
75
|
+
log.success "✓ All #{hook_script_name} hooks passed"
|
76
|
+
log.newline
|
77
|
+
end
|
75
78
|
end
|
76
79
|
|
77
80
|
private
|
@@ -83,10 +86,10 @@ module Overcommit
|
|
83
86
|
log.partial hook_name
|
84
87
|
end
|
85
88
|
|
86
|
-
def print_result(hook, status, output)
|
89
|
+
def print_result(hook, status, output) # rubocop:disable Metrics/CyclomaticComplexity
|
87
90
|
case status
|
88
91
|
when :pass
|
89
|
-
log.success 'OK' unless hook.quiet?
|
92
|
+
log.success 'OK' unless @config['quiet'] || hook.quiet?
|
90
93
|
when :warn
|
91
94
|
log.warning 'WARNING'
|
92
95
|
print_report(output, :bold_warning)
|
data/lib/overcommit/version.rb
CHANGED
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
data/template-dir/hooks/pre-push
CHANGED
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
@@ -73,7 +73,7 @@ begin
|
|
73
73
|
context = Overcommit::HookContext.create(hook_type, config, ARGV, STDIN)
|
74
74
|
config.apply_environment!(context, ENV)
|
75
75
|
|
76
|
-
printer = Overcommit::Printer.new(logger, context)
|
76
|
+
printer = Overcommit::Printer.new(config, logger, context)
|
77
77
|
runner = Overcommit::HookRunner.new(config, logger, context, printer)
|
78
78
|
|
79
79
|
status = runner.run
|
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.33.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-04-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: childprocess
|
@@ -39,48 +39,6 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '1.4'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: rake
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '10.4'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '10.4'
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: rspec
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - "~>"
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '3.0'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - "~>"
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '3.0'
|
70
|
-
- !ruby/object:Gem::Dependency
|
71
|
-
name: travis
|
72
|
-
requirement: !ruby/object:Gem::Requirement
|
73
|
-
requirements:
|
74
|
-
- - "~>"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '1.7'
|
77
|
-
type: :development
|
78
|
-
prerelease: false
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - "~>"
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: '1.7'
|
84
42
|
description: Utility to install, configure, and extend Git hooks
|
85
43
|
email:
|
86
44
|
- eng@brigade.com
|