Configuring Emacs to Define Type of Commit Message
From: https://takeonrules.com/2023/05/17/configuring-emacs-to-automatically-prompt-me-to-define-the-type-of-commit/
< Collapse code block> Expand code block
(defvar bp/version-control/valid-commit-title-prefixes
'("🎁: feature (A new feature)"
"🎨: design/ui (Design changes that don't add feature)"
"⏪: revert (Revert back changes)"
"🐛: bug fix (A bug fix)"
"⚡️: performance (Improvement in performance without adding external feature)"
"📚: docs (Changes to documentation)"
"💄: style (Formatting, missing semi colons, etc; no code change)"
"♻️: refactor (Refactoring production code)"
"📋: tests (Adding tests, refactoring test; no production code change)"
"🧹: chore (Updating build tasks, package manager configs, etc; no production code change)"
"🚧: wip (Work in progress code)"
"✂️: rebase (Rebase needed)")
"Commit message guidelines.")
(defun bp/magit-commit-emoji ()
(interactive)
(let ((splitter ":")
(padding " ")
(commit-type (completing-read "Commit title prefix: "
bp/version-control/valid-commit-title-prefixes nil t)))
(goto-char (point-min))
(insert (car (s-split splitter commit-type)) padding)))
(defun bp/git-commit-mode-hook ()
"If the first line is empty, prompt for commit type and insert it.
Add PADDING between inserted commit type and start of title. For
the `completing-read' show the whole message. But use the
SPLITTER to determine the prefix to include."
(when (and (string= (buffer-name) "COMMIT_EDITMSG")
(save-excursion
(goto-char (point-min))
(beginning-of-line-text)
(looking-at-p "^$")))
(bp/magit-commit-emoji)))
You can send your feedback, queries
here