Created
August 10, 2017 11:29
-
-
Save thejan2009/8b75bc5927167e09126f46ae8d1b6871 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Protect against accidental pushes to certain branches, eval it after magit initializes. | |
(with-eval-after-load 'magit | |
(defadvice magit-git-push | |
(around my-protect-accidental-magit-git-push) | |
"Ask the user for confirmation before pushing to certain branches." | |
(if (member (ad-get-arg 0) '("develop" "master")) | |
(if (yes-or-no-p (format "Push branch %s to %s?" (ad-get-arg 0) (ad-get-arg 1))) | |
ad-do-it | |
(error "Push aborted by user")) | |
ad-do-it)) | |
(ad-activate 'magit-git-push)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment