Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post-delete hook #176

Open
nfarrar opened this issue Aug 18, 2015 · 3 comments
Open

Post-delete hook #176

nfarrar opened this issue Aug 18, 2015 · 3 comments

Comments

@nfarrar
Copy link

nfarrar commented Aug 18, 2015

Would it be possible to add a post-delete hook for running actions automatically when a vcsh repository is deleted?

@vdemeester
Copy link
Contributor

@nfarrar I'm all for hooks, but I'm not sure to see a use case for this one 😊.

@nfarrar
Copy link
Author

nfarrar commented Aug 18, 2015

Maybe unnecessary - the reason I asked was for my current testing/setup use-case:

  1. 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).
  2. 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.

@harendra-kumar
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants