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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Add `RubySyntax` pre-commit hook
* Relax `childprocess` dependency to allow version 1.x
* Add `CodeSpellCheck` pre-commit hook
* Fix deadlock which was more likely to occur when setting `parallelize` on a hook to `false`

## 0.48.1

Expand Down
9 changes: 3 additions & 6 deletions lib/overcommit/hook_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,9 @@ def release_slot(hook)
slots_released = processors_for_hook(hook)
@slots_available += slots_released

if @hooks_left.any?
# Signal once. `wait_for_slot` will perform additional signals if
# there are still slots available. This prevents us from sending out
# useless signals
@resource.signal
end
# Signal every time in case there are threads that are already waiting for
# these slots to be released
@resource.signal
end
end

Expand Down
9 changes: 8 additions & 1 deletion spec/integration/parallelize_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
subject { shell(%w[git commit --allow-empty -m Test]) }

let(:config) { <<-YML }
concurrency: 20
CommitMsg:
TrailingPeriod:
enabled: true
parallelize: false
command: ['ruby', '-e', 'sleep 1']
TextWidth:
enabled: true
parallelize: true
processors: 1
YML

around do |example|
Expand All @@ -22,6 +28,7 @@
end

it 'does not hang' do
Timeout.timeout(5) { subject }
result = Timeout.timeout(5) { subject }
result.stderr.should_not include 'No live threads left. Deadlock?'
end
end