rkotze/git-mob

Support commits with inline message

dideler opened this issue · 4 comments

Commits made with the -m or --message option won't have the editor invoked, so it won't read the commit template to prepopulate the commit message. That means git mob doesn't work with this style of committing.

Committing with an inline message is discouraged for many reasons, but it's still a common practice.

It'd be surprising behaviour if you're in a mob but an inlined commit doesn't have co-authors.

We could use the prepare-commit-msg hook. Tested it with an inline message and it works with a trailer.

Inside the hook we could use the plumbing command git interpret-trailers to add or parse structured information in commit messages.

$ git interpret-trailers -h
usage: git interpret-trailers [--in-place] [--trim-empty] [(--trailer <token>[(=|:)<value>])...] [<file>...]

    --in-place            edit files in place
    --trim-empty          trim empty trailers
    --where <action>      where to place the new trailer
    --if-exists <action>  action if trailer already exists
    --if-missing <action>
                          action if trailer is missing
    --only-trailers       output only the trailers
    --only-input          do not apply config rules
    --unfold              join whitespace-continued values
    --parse               set parsing options
    --trailer <trailer>   trailer(s) to add

Yeah I agree if we ran commit with -m or --message i would expect co-author to show. 👍

Since we agree on the approach, I've changed this from a question to an enhancement.

Solved in release v0.4.0.