项目作者: SystangoTechnologies

项目描述 :
Github app to validate commit message on a pull request
高级语言: JavaScript
项目地址: git://github.com/SystangoTechnologies/commit-message-lint.git
创建时间: 2019-05-28T15:01:06Z
项目社区:https://github.com/SystangoTechnologies/commit-message-lint

开源协议:MIT License

下载


Commit Message Lint

Github app to validate commit message and pull request title on a pull request

Description

This app runs a format check on commit messages and pull request title on the creation of a pull request.

For example, let’s say you specify that a commit message should have a format DDD:message. Here D stand for numeric digit. The app checks if the commit message follows this format. If all the commit messages follow this format, the check returns successful, otherwise failure. The reviewer can then decide if they want to go ahead with the code merge.

App URL

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

Installation

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

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:

  1. PR_TITLE_REGEX: <PR Title Regex>
  2. COMMIT_MESSAGE_REGEX: <Commit Message Regex>
  3. OUTPUT_TITLE_FAIL: Message validation failed!!!
  4. OUTPUT_TITLE_SUCCESS: Message validation passed!!!
  5. VALID_COMMIT_MESSAGE: Commit messages are valid
  6. INVALID_COMMIT_MESSAGE: Commit messages are invalid
  7. SINGLE_OTHER_INVALID_MESSAGE: other message is invalid
  8. MULTIPLE_OTHER_INVALID_MESSAGE: other messages are invalid
  9. VALID_PULL_REQUEST_MESSAGE: Pull request title is valid
  10. 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.

Local setup

Step 1. Clone the application.
Step 2. Run npm install
Step 3. Create .env file in the root directory and set the following environment variables in .env file :

  1. APP_ID - Github app id (get from app settings page)
  2. WEBHOOK_PROXY_URL - URL of the hosted application, use ngrok for local
  3. WEBHOOK_SECRET - webhook secret for security, same as the one set in github app settings
  4. PRIVATE_KEY - Get from github app settings page
  5. LOG_LEVEL - Log level
  6. REGEX_CONFIG_FILE_NAME - config file which contains repo config, keep it as config.yml
  7. GITHUB_BASE_PATH - Github API path, keep it as https://api.github.com

Note : Take values of APP_ID, WEBHOOK_PROXY_URL, WEBHOOK_SECRET, PRIVATE_KEY from https://github.com/settings/apps/commit-message-lint

Step 4. Run npm start to start the application

Resources

Purchase Flow

Identifying and authorizing users for GitHub Apps

Integrating with the GitHub Marketplace API

Contributors

Anshul Soni

Sumit Singhal

Vikas Patidar