overcommit 0.16.0 → 0.17.0
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 +4 -4
- data/lib/overcommit/exceptions.rb +4 -0
- data/lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb +10 -3
- data/lib/overcommit/hook_context/pre_commit.rb +3 -3
- data/lib/overcommit/logger.rb +1 -1
- data/lib/overcommit/utils.rb +5 -2
- data/lib/overcommit/version.rb +1 -1
- data/template-dir/hooks/commit-msg +6 -0
- data/template-dir/hooks/overcommit-hook +6 -0
- data/template-dir/hooks/post-checkout +6 -0
- data/template-dir/hooks/pre-commit +6 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34fb07971b06d936af3a8a4b2cbd4584bfd96506
|
4
|
+
data.tar.gz: a6201349bc528c292c3173d3b4c631dd0fdf76aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35ab2d145525645843ce83eada23ffda314dd443b792213e01dac7e19642a286c5e4fd719f14afcc25505a4fdd1a27f65ea7f1c721af0f572870dfd025d3d970
|
7
|
+
data.tar.gz: 7074b3298a4276c38096f5f6020bf669148cf46591c4be95b67ecfe3af12caddfb09d4c380eab8d3372fae16bc0c8d12f85269beaca362c2725445b2f9252f31
|
@@ -20,6 +20,10 @@ module Overcommit::Exceptions
|
|
20
20
|
# Raised when a {HookRunner} could not be loaded.
|
21
21
|
class HookContextLoadError < StandardError; end
|
22
22
|
|
23
|
+
# Raised when a pipe character is used in the `execute` helper, as this was
|
24
|
+
# likely used in error.
|
25
|
+
class InvalidCommandArgs < StandardError; end
|
26
|
+
|
23
27
|
# Raised when an installation target is not a valid git repository.
|
24
28
|
class InvalidGitRepo < StandardError; end
|
25
29
|
|
@@ -7,9 +7,16 @@ module Overcommit::Hook::PreCommit
|
|
7
7
|
elsif migration_files.none? && schema_files.any?
|
8
8
|
return :fail, "You're trying to change the schema without adding a migration file"
|
9
9
|
elsif migration_files.any? && schema_files.any?
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
# Get the latest version from the migration filename. Use
|
11
|
+
# `File.basename` to prevent finding numbers that could appear in
|
12
|
+
# directories, such as the home directory of a user with a number in
|
13
|
+
# their username.
|
14
|
+
latest_version = migration_files.map do |file|
|
15
|
+
File.basename(file)[/\d+/]
|
16
|
+
end.sort.last
|
17
|
+
|
18
|
+
schema = schema_files.map { |file| File.read(file) }.join
|
19
|
+
up_to_date = schema.include?(latest_version)
|
13
20
|
|
14
21
|
unless up_to_date
|
15
22
|
return :fail, "The latest migration version you're committing is " \
|
@@ -28,7 +28,7 @@ module Overcommit::HookContext
|
|
28
28
|
# issue (e.g. author/email not set or GPG signing key incorrect)
|
29
29
|
raise Overcommit::Exceptions::HookSetupFailed,
|
30
30
|
"Unable to setup environment for #{hook_script_name} hook run:" \
|
31
|
-
"\
|
31
|
+
"\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
|
32
32
|
end
|
33
33
|
|
34
34
|
@changes_stashed = true
|
@@ -75,7 +75,7 @@ module Overcommit::HookContext
|
|
75
75
|
unless result.success?
|
76
76
|
raise Overcommit::Exceptions::HookCleanupFailed,
|
77
77
|
"Unable to cleanup working tree after #{hook_script_name} hooks run:" \
|
78
|
-
"\
|
78
|
+
"\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
@@ -85,7 +85,7 @@ module Overcommit::HookContext
|
|
85
85
|
unless result.success?
|
86
86
|
raise Overcommit::Exceptions::HookCleanupFailed,
|
87
87
|
"Unable to restore working tree after #{hook_script_name} hooks run:" \
|
88
|
-
"\
|
88
|
+
"\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
data/lib/overcommit/logger.rb
CHANGED
data/lib/overcommit/utils.rb
CHANGED
@@ -63,13 +63,16 @@ module Overcommit
|
|
63
63
|
# specified in Overcommit's Gemfile--a nasty consequence of using
|
64
64
|
# `bundle exec overcommit` while developing locally.
|
65
65
|
def execute(args)
|
66
|
+
if args.include?('|')
|
67
|
+
raise Overcommit::Exceptions::InvalidCommandArgs,
|
68
|
+
'Cannot pipe commands with the `execute` helper'
|
69
|
+
end
|
70
|
+
|
66
71
|
with_environment 'RUBYOPT' => nil do
|
67
72
|
Subprocess.spawn(args)
|
68
73
|
end
|
69
74
|
end
|
70
75
|
|
71
|
-
private
|
72
|
-
|
73
76
|
# Calls a block of code with a modified set of environment variables,
|
74
77
|
# restoring them once the code has executed.
|
75
78
|
def with_environment(env)
|
data/lib/overcommit/version.rb
CHANGED
@@ -12,6 +12,12 @@ Signal.trap('INT') do
|
|
12
12
|
exit 130
|
13
13
|
end
|
14
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
|
+
|
15
21
|
# Required for Ruby 1.8 compatibility (for older OSX versions)
|
16
22
|
if RUBY_VERSION.split('.')[0..1] == %w[1 8]
|
17
23
|
require 'rubygems'
|
@@ -12,6 +12,12 @@ Signal.trap('INT') do
|
|
12
12
|
exit 130
|
13
13
|
end
|
14
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
|
+
|
15
21
|
# Required for Ruby 1.8 compatibility (for older OSX versions)
|
16
22
|
if RUBY_VERSION.split('.')[0..1] == %w[1 8]
|
17
23
|
require 'rubygems'
|
@@ -12,6 +12,12 @@ Signal.trap('INT') do
|
|
12
12
|
exit 130
|
13
13
|
end
|
14
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
|
+
|
15
21
|
# Required for Ruby 1.8 compatibility (for older OSX versions)
|
16
22
|
if RUBY_VERSION.split('.')[0..1] == %w[1 8]
|
17
23
|
require 'rubygems'
|
@@ -12,6 +12,12 @@ Signal.trap('INT') do
|
|
12
12
|
exit 130
|
13
13
|
end
|
14
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
|
+
|
15
21
|
# Required for Ruby 1.8 compatibility (for older OSX versions)
|
16
22
|
if RUBY_VERSION.split('.')[0..1] == %w[1 8]
|
17
23
|
require 'rubygems'
|
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.17.0
|
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-
|
12
|
+
date: 2014-09-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: childprocess
|
@@ -174,3 +174,4 @@ signing_key:
|
|
174
174
|
specification_version: 4
|
175
175
|
summary: Git hook manager
|
176
176
|
test_files: []
|
177
|
+
has_rdoc:
|