Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions spec/integration/disable_overcommit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,32 @@
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason the HOMEBREW_SYSTEM environment variable has a newline in the key name? (see the single quote above)

This likely explains why the tests don't work.

) do
touch 'blah'
`git add blah`
example.run
end
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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/overcommit-hook
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/post-merge
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/post-rewrite
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/pre-rebase
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down
4 changes: 4 additions & 0 deletions template-dir/hooks/prepare-commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -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 " \
Expand Down