Code Monkey home page Code Monkey logo

git-msg-prefix.el's Introduction

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 my blog.

How

Install

This package will be in melpa shortly. For now, get it from https://github.com/kidd/git-msg-prefix.el

(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))

Usage

Add a hook to activate run the function when starting to write your commit

(add-hook 'git-commit-mode-hook 'git-msg-prefix)
(setq git-msg-prefix-input-method 'helm-comp-read)

Otherwise, add a keybinding to that function or run it manually from the minibuffer.

(local-set-key
 (kbd "C-c i")
 'git-msg-prefix)

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]>

git-msg-prefix.el's People

Contributors

kidd avatar seblemaguer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.