Commit message patterns

:grey-exclamation: Available in the Enterprise version

Salto Administrators can set commit message patterns in order to enforce some structure on users' git commit messages. For example, an administrator may want to ensure that every git commit contains a valid ticket ID, to prevent commits that can't be traced back to tickets.

Defining commit message patterns

📘

Only organizational administrators can change commit message pattern definitions

To set up a new commit message pattern, go to the organizational settings menu, and locate the "Commit Message Patterns" section.

756756

Click "Add Pattern" to set up a pattern and a help message.

The pattern should be a JavaScript compatible regular expression (see examples below). Any git commit will be matched against this pattern; commits which don't contain it in their title or message will be rejected.

An optional help message can be presented to users who try to commit messages which don't contain the defined pattern. Use it to help users craft a correct, compliant commit title and message.

781781

You can then decide whether your pattern is enforced

  • On all repositories
  • On specific repositories
  • On specific branches of specific repositories

Note that if more than one pattern is defined on a specific branch or repository, commits to that destination should match all those patterns.

Matching on specific patterns can also be disabled or enabled by using the toggle on the right:

758758

Pattern examples

Patterns should be valid JavaScript regular expressions. Here are some examples you can edit and use:

  • ACME-\d+ : This will make sure all commit messages contain a ticket ID which starts with "ACME", followed by a hyphen, and then some number. The ticket ID can appear anywhere in the title or the message itself.
  • ^ACME-\d+ : This is similar to the above, but makes sure that the commit title starts with the ticket ID