Skip to content
Merged
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
4 changes: 2 additions & 2 deletions spec/integration/committing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
around do |example|
repo do
File.open('.overcommit.yml', 'w') { |f| f.write(config) }
`overcommit --install > #{File::NULL}`
install_overcommit_hooks
example.run
end
end
Expand Down Expand Up @@ -71,7 +71,7 @@

around do |example|
repo do
`overcommit --install > #{File::NULL}`
install_overcommit_hooks
File.open('.overcommit.yml', 'w') { |f| f.write(config) }
File.open('test.txt', 'w') { |f| f.write(file_contents) }
`git add test.txt`
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/configuration_signing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

around do |example|
repo do
`overcommit --install > #{File::NULL}`
install_overcommit_hooks
echo(config.to_yaml, '.overcommit.yml')

`overcommit --sign` if configuration_signed
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/disable_overcommit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

around do |example|
repo do
`overcommit --install > #{File::NULL}`
install_overcommit_hooks
Overcommit::Utils.with_environment('OVERCOMMIT_DISABLE' => overcommit_disable) do
touch 'blah'
`git add blah`
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/hook_signing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
around do |example|
repo do
echo(config.to_yaml, '.overcommit.yml')
`overcommit --install > #{File::NULL}`
install_overcommit_hooks

echo(hook_script, script_path)
FileUtils.chmod(0o755, script_path)
Expand Down Expand Up @@ -87,7 +87,7 @@
around do |example|
repo do
echo(config.to_yaml, '.overcommit.yml')
`overcommit --install > #{File::NULL}`
install_overcommit_hooks

echo(hook_script, script_path)
FileUtils.chmod(0o755, script_path)
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/parallelize_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
around do |example|
repo do
File.open('.overcommit.yml', 'w') { |f| f.write(config) }
`overcommit --install > #{File::NULL}`
install_overcommit_hooks
example.run
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/protected_branches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
end

shared_context 'ProtectedBranches enabled' do
before { `overcommit --install > #{File::NULL}` }
before { install_overcommit_hooks }
end

shared_examples 'push succeeds' do
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/resolving_cherry_pick_conflict_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
`git commit -m "Add Branch 2 addition"`
`git checkout -q master`
`git cherry-pick branch1 > #{File::NULL} 2>&1`
`overcommit --install > #{File::NULL}`
install_overcommit_hooks
`git cherry-pick branch2 > #{File::NULL} 2>&1` # Results in cherry-pick conflict
echo('Conflicts Resolved ', 'some-file') # Fail trailing whitespace hook
`git add some-file`
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/resolving_merge_conflict_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
`git checkout -q master`
`git merge branch1`
`git merge branch2` # Results in merge conflict
`overcommit --install > #{File::NULL}`
install_overcommit_hooks
echo('Conflicts Resolved', 'some-file')
`git add some-file`
example.run
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/worktree_signing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
raise "Unable to create worktree: #{result.stderr}" unless result.success?

echo(config.to_yaml, '.overcommit.yml')
`overcommit --install > #{File::NULL}`
install_overcommit_hooks
`overcommit --sign`

Dir.chdir(linked_worktree) do
Expand Down
15 changes: 15 additions & 0 deletions spec/support/fixture_installation.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

require 'stringio'

# Prepare installed hooks without booting a separate fixture CLI process.
# CLI and Gemfile-loading integration tests still invoke the real executable.
module ShellHelpers
def install_overcommit_hooks
%w[repo_root git_dir].each { |name| Overcommit::Utils.instance_variable_set("@#{name}", nil) }
logger = Overcommit::Logger.new(StringIO.new)
Overcommit::Installer.new(logger).run(Dir.pwd, action: :install)
ensure
%w[repo_root git_dir].each { |name| Overcommit::Utils.instance_variable_set("@#{name}", nil) }
end
end
Loading