Skip to content

Instantly share code, notes, and snippets.

@rawsyntax
Last active January 5, 2019 15:41
Show Gist options
  • Save rawsyntax/4565542 to your computer and use it in GitHub Desktop.
Save rawsyntax/4565542 to your computer and use it in GitHub Desktop.
magit commit hook template
;; 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