Last active
January 5, 2019 15:41
-
-
Save rawsyntax/4565542 to your computer and use it in GitHub Desktop.
magit commit hook template
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
;; TODO: pull author initials from (user-full-name) | |
(setq author-initials "EH") | |
(defun set-pivotal-story-id (id) | |
"sets current pivotal tracker story id" | |
(interactive "spivotal-story-id:") | |
(progn | |
(setq pivotal-story-id id))) | |
;; TODO: only do this if dir is under ~/source ?? | |
;; TODO: prompt for pivotal-story-id if not set? or perhaps use 000 | |
(defun su/magit/commit-message-template (&rest discard) | |
"Have a template for the commit message" | |
(unless current-prefix-arg ;; ignore commit amends | |
(let ((tag (format "[%s] [%s] " author-initials pivotal-story-id))) | |
(goto-char (point-min)) | |
(unless (search-forward tag nil t) | |
(insert tag)) | |
(goto-char (point-max)) | |
))) | |
(add-hook 'magit-log-edit-mode-hook 'su/magit/commit-message-template) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment