git-msg-prefix.el
git-msg-prefix.el copied to clipboard
Insert a piece of earlier vcs commits in your current commit message
-
git-msg-prefix.el ** What In many organizations, git commits have to have a structure, like starting with one word from a list (Add, Fix, Clean, Remove...).
In other projects, you should start the commit messages with the issue number, or a specific tag referring to the feature you're developing (Billing-123).
git-msg-prefix is intended to solve this repetitive task, by providing a prompt with some customized list of options. The default command is to present a searchable list of the previous commits (more recent first), and lets you select the one you want. This list of candidates is configurable via
git-msg-prefix-log-command.Once selected, the relevant part of the commit line will be extracted from the choosen candidate (via the regex in git-msg-prefix-regex, and the matched text will be inserted in the current buffer.
A gif is worth a 10^3 words: [[./git-msg-prefix.gif]]
Release post in [[http://puntoblogspot.blogspot.com.es/2017/07/announcing-commit-msg-prefix.html][my blog]]. ** How *** Install This package will be in melpa shortly. For now, get it from https://github.com/kidd/git-msg-prefix.el #+BEGIN_SRC emacs-lisp (use-package git-msg-prefix :ensure t :config (setq git-msg-prefix-log-flags " --since='1 week ago' " git-msg-prefix-input-method 'helm-comp-read) (add-hook 'git-commit-mode-hook 'git-msg-prefix)) #+END_SRC *** Usage Add a hook to activate run the function when starting to write your commit #+BEGIN_SRC emacs-lisp (add-hook 'git-commit-mode-hook 'git-msg-prefix) (setq git-msg-prefix-input-method 'helm-comp-read) #+END_SRC
Otherwise, add a keybinding to that function or run it manually from the minibuffer. #+BEGIN_SRC emacs-lisp (local-set-key (kbd "C-c i") 'git-msg-prefix) #+END_SRC
*** Configure There are 3 variables to configure:
- ~git-msg-prefix-log-command~: defaults to "git log
--pretty=format:\"%s\""
- ~git-msg-prefix-log-flags~: defaults to ""
- ~git-msg-prefix-regex~: defaults to "^\\([^ ]*\\) "
- ~git-msg-prefix-input-method~: defaults to
ido-completing-read. Change it to your favourite input
method. ('completing-read 'ido-completing-read
'git-msg-prefix-helm-read 'ivy-read)
** Who Raimon Grau [email protected]