overcommit 0.16.0 → 0.17.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e7a230157adc2af8bc8cf4b209e6b50d99d67a7
4
- data.tar.gz: 190432fe93e3a69293a69b93bbd75460923f72b1
3
+ metadata.gz: 34fb07971b06d936af3a8a4b2cbd4584bfd96506
4
+ data.tar.gz: a6201349bc528c292c3173d3b4c631dd0fdf76aa
5
5
  SHA512:
6
- metadata.gz: 4e98e7cbe0771bb681380819fc688d27c06b6106ebb884d8bbd71ef132a77916eacf8d4fe42b997e6d70edc868436c47a7a437215258d091e337fe2474b9d001
7
- data.tar.gz: 8481d1109df9d34d2d6306fbfb56db74e20a002444d91775aba9d5553a3e149cb37b9a0dbfacd33868f7a328fcb1a55f5371fc3f22075e15da679329e7b1b37c
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
- latest_version = migration_files.map { |file| file[/\d+/] }.sort.last
11
- schema = schema_files.map { |file| File.read(file) }.join
12
- up_to_date = schema.include?(latest_version)
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
- "\n#{result.stderr}"
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
- "\n#{result.stderr}"
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
- "\n#{result.stderr}"
88
+ "\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
89
89
  end
90
90
  end
91
91
 
@@ -19,7 +19,7 @@ module Overcommit
19
19
  end
20
20
 
21
21
  def bold(str)
22
- color('1;37', str)
22
+ color('1', str)
23
23
  end
24
24
 
25
25
  def error(str)
@@ -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)
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Overcommit
3
- VERSION = '0.16.0'
3
+ VERSION = '0.17.0'
4
4
  end
@@ -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.16.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-08-01 00:00:00.000000000 Z
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: