Commit message
  • Updated on 22 Apr 2019
  • 1 minute to read
  • Contributors
  • Share
  • Dark
    Light

Commit message

  • Share
  • Dark
    Light

Go to Datree's "custom rules" tab and click on "create new rule" button

3x-7d2fdb6-1.png

1. Choose custom rule type

Step 1 at the wizard - choose "custom commit message"

3x-32c848c-2.png

2. Edit custom rule details

The rule description will be shown on the custom rule dashboard, while the rule title will be used on GitHub "smart policy" check

3x-e46c2fe-3.png

3. Configure your custom rule

  • Regular Expression - which pattern should be validated for the commit message

3x-0fa839a-Screen_Shot_2019-01-23_at_11.46.44.png

ℹ️ The following regular expression will verify that every commit messages starts with a capital letter and must be between 5-50 characters

 ^[A-Z].{4,49} $ 
Regular Expression Explanation
^ Assert position at the beginning of the string
[A-Z] Match one letter from A to Z
. Match any character
{4,49} Between 4 and 49 times
$ Assert position at the end of the string
  • Match all commits - will all the commits messages in the pull request needs to follow the given regex pattern?

  • Ignore merge commits - ignore auto-created commits by GitHub when merging a pull request?

3x-7f818fa-8.png

  • Test Text - an input box to test your regex 😎

3x-4172c9b-Screen_Shot_2019-01-23_at_11.28.51.png

4. Wrap it up

Click on the "create" button to add your custom policy to the policies menu on the left

3x-709dba6-5.png

By default, the rule will not be enabled until explicitly defining repositories

3x-bfe2ea0-6.png

5. See your custom policy in action!

Commit message will NOT pass the policy:

3x-fdbbf33-7.png

3x-f0fa68a-Screen_Shot_2019-01-23_at_11.48.10.png

After fixing the commit message:

9b18611-Screen_Shot_2019-04-01_at_18.06.24

Was this article helpful?