Skip to content

Commit Message Lint 2.2.1

sumits-systango edited this page Apr 16, 2020 · 1 revision

Installation and Setup

Release 2.2.1 - Permissions Update

The app required read access to code. This permission is now removed as this is not required. This was required for private repos which is no longer needed.

Installation

Use the Github's app section or the app URL to install the app to your repository.

App URL

https://github.com/apps/commit-message-lint

Configuration

You would need to add a configuration folder named .github at the root of your repository. The folder should contain a file named config.yml. This file will serve as the configuration and the contents of that file will be:

PR_TITLE_REGEX: <PR Title Regex>
COMMIT_MESSAGE_REGEX: <Commit Message Regex>

Update

Following optional configuration parameters are added to support dynamic message in response:

PR_TITLE_REGEX: <PR Title Regex>
COMMIT_MESSAGE_REGEX: <Commit Message Regex>
OUTPUT_TITLE_FAIL: Message validation failed!!!
OUTPUT_TITLE_SUCCESS: Message validation passed!!!
VALID_COMMIT_MESSAGE: Commit messages are valid
INVALID_COMMIT_MESSAGE: Commit messages are invalid
SINGLE_OTHER_INVALID_MESSAGE: other message is invalid
MULTIPLE_OTHER_INVALID_MESSAGE: other messages are invalid
VALID_PULL_REQUEST_MESSAGE: Pull request title is valid
INVALID_PULL_REQUEST_MESSAGE: Pull request title is invalid

Usage

Go to the checks section on your PR to see the result of the check run performed by the app. It will show you the result as well as the commit messages which failed.

If a developer does not adhere to the format, the check section of PR will show failure for this app. Then the reviewer can take the decision on whether to merge the PR or not.

If the app is not configured and the config.yml file is not provided, the app will mark the check as success but the message will show that the file is not configured.

The idea is to enforce developers to follow a specific format for their commit messages and PR title, so that there is consistency. Also, this allows organisations to integrate other tools which function by extracting information out of the commit messages.

Re-run

This application also support re-run. For example, if your check fails due to invalid PR title, just edit the existing PR title and click on the re-run button present in the checks section.

Example

Let's take below regex as examples for PR title and commit messages:

PR_TITLE_REGEX: /((?:[a-z][a-z]+))(\d{3})(:)([a-z0-9])/i
COMMIT_MESSAGE_REGEX: /(#)(#)((?:[a-z][a-z]+))(\d{3})(:)([a-z0-9])/i

For above regex, the corresponding valid messages would be:

PR message - JIR123:login feature

Commit message - ##JIR302:login feature