-
Notifications
You must be signed in to change notification settings - Fork 280
Closed
Description
After upgrading overcommit from 0.41.0 to 0.42.0, the first time I attempt to use git commit on an overcommit-enabled project I get this crash:
$ git commit
Directory not empty @ dir_s_rmdir - /Users/mbrictson/Code/myapp/.git/hooks/old-hooks
/Users/mbrictson/.rbenv/versions/2.5.0/lib/ruby/2.5.0/fileutils.rb:250:in `rmdir'
/Users/mbrictson/.rbenv/versions/2.5.0/lib/ruby/2.5.0/fileutils.rb:250:in `block in rmdir'
/Users/mbrictson/.rbenv/versions/2.5.0/lib/ruby/2.5.0/fileutils.rb:249:in `each'
/Users/mbrictson/.rbenv/versions/2.5.0/lib/ruby/2.5.0/fileutils.rb:249:in `rmdir'
/Users/mbrictson/Code/overcommit/lib/overcommit/installer.rb:142:in `preserve_old_hooks'
/Users/mbrictson/Code/overcommit/lib/overcommit/installer.rb:58:in `update'
/Users/mbrictson/Code/overcommit/lib/overcommit/installer.rb:20:in `run'
.git/hooks/pre-commit:67:in `<main>'
Report this bug at https://github.com/brigade/overcommit/issues
Digging in a bit further, I found that 3c37254 in 0.42.0 made a trivial change to the git hooks. Thus, the first time overcommit 0.42 is used on a existing overcommit-enabled project, it will attempt to upgrade to the new version of the git hooks.
It backs up any existing hooks to old_hooks_path, and then reaches this line:
# Remove old-hooks directory if empty
FileUtils.rmdir(old_hooks_path)For me, this fails with a "Directory not empty" error. Seems like there should be a guard clause here that skips the rmdir if the directory is not empty?
Metadata
Metadata
Assignees
Labels
No labels