Post-delete hook
Opened this issue · 3 comments
Would it be possible to add a post-delete hook for running actions automatically when a vcsh repository is deleted?
@nfarrar I'm all for hooks, but I'm not sure to see a use case for this one 😊.
Maybe unnecessary - the reason I asked was for my current testing/setup use-case:
- When cloning a repository, I have a pre-merge-unclobber hook that moves files out of the way (into
~/.cache/vcsh/clobbered/relative/to/home/filename
). - While setting up my repositories, I'm doing lots of clones. Sometimes those fail for various reasons ... and that file has already been moved out of the way. I then delete the repository (
vcsh delete <repo>
), but now the system is in a different state then when it failed (the original file is now in the backup location). If I clone again, (and another conflict with the same file occurs - though this shouldn't be possible), the backup could be overwritten - so typically I move the backup file to the original location, then attempt to clone the repository again.
WIth a pre-delete hook (or maybe post-delete hook?), I could automatically move the backup file back to it's original location, leaving the system in the original state before I attempted to the (failed) clone operation.
For more standard use-cases, this could be leveraged with the pre-commit hook
to restore the original files whenever removing a repository, leaving the system back in the original state.
I use a pre-command
hook to intercept the delete command so that I can deinit any submodules:
if test "$VCSH_COMMAND" = "delete"
then
vcsh $VCSH_REPO_NAME submodule deinit .
fi
Perhaps you can use a post-command
hook for your purpose. This is sort of hack to implement whatever hook you want.