Skip to content

Commit 7c85c66

Browse files
committed
Don't attempt to remove old-hooks directory if non-empty
Attempt to delete the old-hooks directory _only_ if it is empty, otherwise we get an exception. Travis has been passing this test for a while, but it fails when running on macOS, so there is likely some platform difference at play here. Fixes sds#554
1 parent 838a571 commit 7c85c66

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/overcommit/installer.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ def preserve_old_hooks
138138
FileUtils.mv(hook_file, old_hooks_path)
139139
end
140140
end
141-
# Remove old-hooks directory if empty
142-
FileUtils.rmdir(old_hooks_path)
141+
# Remove old-hooks directory if empty (i.e. no old hooks were preserved)
142+
FileUtils.rmdir(old_hooks_path) if Dir.entries(old_hooks_path).size <= 2
143143
end
144144

145145
def restore_old_hooks

0 commit comments

Comments
 (0)