Always check for backup when uninstalling - use presence of backup to indicate if we are installed.
Use a real git repository in tests, not just a folder called .git. Create it in /tmp/ so that we don't walk up the tree to the repo of this project.
Prior to this PR, on uninstallation, you would only get a git-hooks is not installed error if there was no .git/hooks folder, but installation would never remove that folder. It would replace it, if there was a backup to replace it with, or leave it if there was not.
In practise having no hooks folder would never happen as git will automatically create a hooks folder with samples by default. You have to take steps to remove it.
After this PR, install will always make a backup of the current hooks folder, or make a placeholder if it didn't exist. It will use the presence of this backup to detect if it has been installed, and uninstall correctly, giving an error whenever it is not installed, even if the user already had manually added git hooks for the project.
Coverage increased (+1.01%) to 94.949% when pulling 6a1945efa5e41a934146ba3c823590fc69426d0c on rjmunro:feature/always-backup-hooks into aaf26a1364e10049e9e9bfddfb77935de5a8699c on tarmolov:master.
Coverage increased (+1.01%) to 94.949% when pulling 6a1945efa5e41a934146ba3c823590fc69426d0c on rjmunro:feature/always-backup-hooks into aaf26a1364e10049e9e9bfddfb77935de5a8699c on tarmolov:master.
Coverage increased (+1.01%) to 94.949% when pulling 6a1945efa5e41a934146ba3c823590fc69426d0c on rjmunro:feature/always-backup-hooks into aaf26a1364e10049e9e9bfddfb77935de5a8699c on tarmolov:master.
Coverage increased (+2.02%) to 95.96% when pulling 2597d0e06e0a0514236ca2e3c96f875055e614f8 on rjmunro:feature/always-backup-hooks into aaf26a1364e10049e9e9bfddfb77935de5a8699c on tarmolov:master.
.git
. Create it in /tmp/ so that we don't walk up the tree to the repo of this project.Prior to this PR, on uninstallation, you would only get a
git-hooks is not installed
error if there was no .git/hooks folder, but installation would never remove that folder. It would replace it, if there was a backup to replace it with, or leave it if there was not.In practise having no hooks folder would never happen as git will automatically create a hooks folder with samples by default. You have to take steps to remove it.
After this PR, install will always make a backup of the current hooks folder, or make a placeholder if it didn't exist. It will use the presence of this backup to detect if it has been installed, and uninstall correctly, giving an error whenever it is not installed, even if the user already had manually added git hooks for the project.
I've been working on a solution to https://github.com/tarmolov/git-hooks-js/issues/48, but couldn't get new tests to pass until I sorted out this anomaly.