We have a convention that every commit message begins with an issue number.
I'd like to be able to programmatically insert the issue number part (computed by a separate function) into the commit window of Magit, when it first opens (that is, on pressing C C).
How do I best do it? Where to look?
UPDATE: Here's what I'm currently using.
(defun my-extract-branch-tag (branch-name)
(let ((TICKET-PATTERN "\\(?:[[:alpha:]]+-\\)?\\([[:alpha:]]+-[[:digit:]]+\\)-.*"))
(when (string-match-p TICKET-PATTERN branch-name)
(s-upcase (replace-regexp-in-string TICKET-PATTERN "[\\1] " branch-name)))))
(defun my-git-commit-insert-branch ()
(insert (my-extract-branch-tag (magit-get-current-branch))))
(add-hook 'git-commit-setup-hook 'my-git-commit-insert-branch)
For a branch name like <username>-foo-123-<explanatory part>
it produces [FOO-123]
in the first line of the commit message, to allow easy ticket auto-linking in Jira.