Merge Commit Message Validator for Pull Requests
Last updated
Was this helpful?
Last updated
Was this helpful?
This repository provides a Forge app for validating merge commit messages in Bitbucket pull requests. It ensures that pull requests targeting specific branches meet configurable standards for commit message patterns and merge strategies.
Pull Request Validation:
Validates pull requests targeting specific branches (main
, master
, boost_1.80.0
).
Ensures the merge strategy is set to squash
.
Checks the merge commit message against a configurable regex pattern.
Configurable Regex:
Admins can update the regex pattern used for validating merge commit messages via a user-friendly UI.
src/merge-checks/index.ts
This file contains the backend logic for validating pull requests. Key functionalities include:
Fetching Pull Request Details:
Retrieves the destination branch and checks if it's one of the allowed branches (main
, master
, boost_1.80.0
).
Validation Logic:
Ensures the merge strategy is set to squash
.
Validates the merge commit message against a regex pattern retrieved from Forge storage.
Dynamic Configuration:
The regex pattern for commit messages is fetched from Forge storage, allowing it to be updated without code changes.
Error and Success Handling:
Logs and returns appropriate responses based on validation results.
frontend/TitleSubstringForm.tsx
This file provides the frontend interface for configuring the regex pattern. It is built using Atlassian's UI Kit 2.
Key Features:
A form to set the merge commit message regex pattern.
Validates user input to ensure the field is not empty.
Displays success messages when changes are applied.
Automatically saves the regex pattern to Forge storage via an invoke
resolver.
Clone the repository:
Install Dependencies: Make sure you have the Forge CLI installed. Then install dependencies:
Deploy the Forge App: Deploy the app to your Atlassian account.
Run the App: To test the app locally, use:
Navigate to the app's configuration UI to set a custom regex for validating merge commit messages. For example:
Regex: ^JIRA-\d+: .*
Ensures commit messages start with a JIRA ticket ID.
When a pull request is created or updated, the app validates:
The destination branch (must be main
, master
, or boost_1.80.0
).
The merge strategy (must be squash
).
The commit message (must match the configured regex).
Successful Validation:
A pull request targets main
.
The merge strategy is squash
.
The commit message matches the regex.
Failure Cases:
The destination branch is not allowed.
The merge strategy is not squash
.
The commit message does not match the regex.
Fork the repository.
Make your changes in a new branch.
Submit a pull request with a detailed description.
Git Repo