diff --git a/spec/integration/disable_overcommit_spec.rb b/spec/integration/disable_overcommit_spec.rb index 04243cd5..202c9af2 100644 --- a/spec/integration/disable_overcommit_spec.rb +++ b/spec/integration/disable_overcommit_spec.rb @@ -8,7 +8,10 @@ around do |example| repo do `overcommit --install > #{File::NULL}` - Overcommit::Utils.with_environment('OVERCOMMIT_DISABLE' => overcommit_disable) do + Overcommit::Utils.with_environment( + 'OVERCOMMIT_DISABLE' => overcommit_disable, ' + HOMEBREW_SYSTEM' => homebrew_system + ) do touch 'blah' `git add blah` example.run @@ -16,9 +19,21 @@ end end - context 'when the OVERCOMMIT_DISABLE environment variable is set' do - let(:overcommit_disable) { '1' } + context 'when the HOMEBREW_SYSTEM environment variable is not set' do + let(:overcommit_disable) { '0' } + let(:homebrew_system) { nil } + it 'exits successfully' do + subject.status.should == 0 + end + + it 'runs the hooks' do + subject.stderr.should include 'Running pre-commit hooks' + end + end + context 'when the HOMEBREW_SYSTEM environment variable is set' do + let(:overcommit_disable) { '0' } + let(:homebrew_system) { 'Macintosh' } it 'exits successfully' do subject.status.should == 0 end @@ -31,6 +46,7 @@ context 'when the OVERCOMMIT_DISABLE environment variable is set to zero' do let(:overcommit_disable) { '0' } + let(:homebrew_system) { nil } it 'exits successfully' do subject.status.should == 0 @@ -43,6 +59,7 @@ context 'when the OVERCOMMIT_DISABLE environment variable is unset' do let(:overcommit_disable) { nil } + let(:homebrew_system) { nil } it 'exits successfully' do subject.status.should == 0 diff --git a/template-dir/hooks/commit-msg b/template-dir/hooks/commit-msg index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/commit-msg +++ b/template-dir/hooks/commit-msg @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/overcommit-hook b/template-dir/hooks/overcommit-hook index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/overcommit-hook +++ b/template-dir/hooks/overcommit-hook @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/post-checkout b/template-dir/hooks/post-checkout index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/post-checkout +++ b/template-dir/hooks/post-checkout @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/post-commit b/template-dir/hooks/post-commit index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/post-commit +++ b/template-dir/hooks/post-commit @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/post-merge b/template-dir/hooks/post-merge index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/post-merge +++ b/template-dir/hooks/post-merge @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/post-rewrite b/template-dir/hooks/post-rewrite index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/post-rewrite +++ b/template-dir/hooks/post-rewrite @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/pre-commit b/template-dir/hooks/pre-commit index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/pre-commit +++ b/template-dir/hooks/pre-commit @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/pre-push b/template-dir/hooks/pre-push index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/pre-push +++ b/template-dir/hooks/pre-push @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/pre-rebase b/template-dir/hooks/pre-rebase index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/pre-rebase +++ b/template-dir/hooks/pre-rebase @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \ diff --git a/template-dir/hooks/prepare-commit-msg b/template-dir/hooks/prepare-commit-msg index 8b8c118c..2bd650a1 100755 --- a/template-dir/hooks/prepare-commit-msg +++ b/template-dir/hooks/prepare-commit-msg @@ -19,6 +19,10 @@ if ENV['OVERCOMMIT_DISABLE'].to_i != 0 || ENV['OVERCOMMIT_DISABLED'].to_i != 0 exit end +# Homebrew uses an isolated version of Ruby for installing git repositories +# Disable Overcommit if the process running is a Homebrew installation. +exit if ENV['HOMEBREW_SYSTEM'] + hook_type = File.basename($0) if hook_type == 'overcommit-hook' puts "Don't run `overcommit-hook` directly; it is intended to be symlinked " \