Skip to content

Latest commit

 

History

History
135 lines (117 loc) · 3.76 KB

commit-msg.md

File metadata and controls

135 lines (117 loc) · 3.76 KB

Back to top

Commit Message Validation

Default commit message format is:

[Commit verb] [Issue Key]: [Issue Summary]
[Commit Message]

E.g. for the bug:

Fixed PRJNM-256: An email validation doesn't work
 - Added missed email validator.

Where PNM-25 is an issue key of your tasks tracker.

There are available commit verbs:

  • Implemented (for tasks)
  • Fixed (for bugs)
  • Refactored (for commits which contains refactoring only)
  • CR Change(s) ("changes" or "change", for applying code review changes)

NOTE: Actually this can be extended. Please take a look some specific customization of commit message format.

Ignore commit message validation

About ignoring validation please read here.

Short commit message

Your valid commit message may looks like this:

I did it!

But due to using short verbs like I or R, etc., please use - in the beginning. It will be considered as verb instead.

- I did it!

There are integrations with task trackers

  • JIRA
  • GitHub

JIRA Integration

Please take a look wizard example.

Short Issue Commit

So, if you want to be lazy productive... :) If you tired of copy-pasting issue key and summary that there is good news. If you'd like to speed up of writing commit-verb that there is good news.

Option #1 (JIRA only): Omit issue summary

You may write it shortly with using JIRA project key:

F PRJNM-256 Added missed email validator.

The system will connect to JIRA and get an issue summary. Also it will recognize the commit-verb. There are following short-names:

  • I for Implemented
  • F for Fixed
  • R for Refactored
  • C for CR Changes

Option #2: Omit project key.

And a project key can be omitted.

F 256
 - Added missed email validator.

In this case the system will find a project key and set it (it should be set in this case).

Option #3: Omit verbs

You may omit verbs F and I. It will be identified by issue type.

256 Added missed email validator.

or verb R for refactoring (C - for CR Changes)

R 256 Reformatted code

or for list

256 Added missed email validator.
 - Reformatted code

In this case the system will take default verb by issue type. For bug - Fixed and for tasks - Implemented. Of course if you're making refactoring or applying code review you have to set related verb.

Option #4

Also, you may declare "active task" by similar command and don't care about numbers in commit messages:

$ commithook tracker:task 256

More info about command tracker:task here.

The value can be checked w/o last argument. And a message will be simplest:

 - Added missed email validator.
 - Reformatted code

JIRA issue type configuration map

There is predefined configuration:

<?xml version="1.0"?>
<config>
    <hooks>
        <commit-msg>
            <message>
                <issue>
                    <type>
                        <tracker>
                            <jira>
                                <default>
                                    <New_Type>task</New_Type>
                                </default>
                            </jira>
                        </tracker>
                    </type>
                </issue>
            </message>
        </commit-msg>
    </hooks>
</config>

You extend it with adding new nodes by adding new config node. E.g. we need to map New Type to type task.

$ commithook config --xpath hooks/commit-msg/message/issue/type/tracker/jira/default/New_Type task

Be aware about numbers. :)

Please always keep an eye on issue numbers. That's all just to be more lazy productive! ;D

Back to top