Statocles
Statocles copied to clipboard
Handle SIGINT during git deploy to switch back branches
When we're deploying to a git repo, we often need to switch branches. I've been having a problem with my deploy target where it doesn't respond to push. So, I eventually Ctrl+C to stop. This leaves me on the other branch, forcing me to switch back to master before being able to run the deploy again.
If we add a handler for SIGINT, we can try to move back to the original branch when there's a problem. We must not leave the branch in an inconsistent state, though, so if there's uncommitted content, we must not switch branches (git will complain, anyway).