mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add check to run during merge queue to ensure a custom commit message has been written
This commit is contained in:
4
.github/workflows/on-trigger.yml
vendored
4
.github/workflows/on-trigger.yml
vendored
@@ -62,6 +62,10 @@ jobs:
|
||||
if: ${{ github.event_name == 'push' && github.ref_type == 'branch' && contains(fromJSON('["develop", "release"]'), github.ref_name) }}
|
||||
uses: ./.github/workflows/reusable-check-missing-commits.yml
|
||||
|
||||
check-single-commit:
|
||||
if: ${{ github.event_name == 'merge_group' }}
|
||||
uses: ./.github/workflows/reusable-check-commit-message.yml
|
||||
|
||||
build-test:
|
||||
uses: ./.github/workflows/reusable-build-test.yml
|
||||
strategy:
|
||||
|
||||
72
.github/workflows/reusable-check-commit-message.yml
vendored
Normal file
72
.github/workflows/reusable-check-commit-message.yml
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# This workflow checks that the commit message follows our expected format.
|
||||
name: Check commit message
|
||||
|
||||
# This workflow can only be triggered by other workflows.
|
||||
on: workflow_call
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}-single-commit
|
||||
cancel-in-progress: true
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Check commit message
|
||||
env:
|
||||
MESSAGE: |
|
||||
|
||||
If you are reading this, then the commit message does not match our
|
||||
expected format. See CONTRIBUTING.md for instructions.
|
||||
|
||||
It is further possible that you did not run the script in
|
||||
`bin/git/squash-commits.sh` before clicking the 'Merge when ready'
|
||||
button in GitHub's UI.
|
||||
run: |
|
||||
set -o pipefail
|
||||
|
||||
COMMIT_MSG='${{ github.event.head_commit.message }}'
|
||||
echo "Commit message: ${COMMIT_MSG}"
|
||||
|
||||
# If the commit title contains a prefix then it must be one we permit.
|
||||
COMMIT_TITLE=$(echo "${COMMIT_MSG}" | head -n1)
|
||||
echo "Commit title: '${COMMIT_TITLE}'"
|
||||
|
||||
if [[ "${COMMIT_TITLE}" =~ ^[^:]+:[^:]+ ]]; then
|
||||
if ! [[ "${COMMIT_TITLE}" =~ ^(build|chore|docs|fix|perf|refactor|test):[^:]+ ]]; then
|
||||
echo "Commit title prefix is not permitted."
|
||||
echo "${MESSAGE}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# The commit description may not only contain a list of commits, which
|
||||
# is what happens if a PR containing multiple commits is squashed and
|
||||
# merged by GitHub.
|
||||
COMMIT_DESC=$(echo "${COMMIT_MSG}" | tail -n+3)
|
||||
echo "Commit description: '${COMMIT_DESC}'"
|
||||
|
||||
while IFS=$'\n' read -r LINE; do
|
||||
echo "Processing: ${LINE}"
|
||||
# Check for lines starting with '-' or '*' followed by a space.
|
||||
if ! [[ "${LINE}" =~ ^[[:space:]]*[-*][[:space:]]+.* ]]; then
|
||||
exit 0
|
||||
fi
|
||||
# Check if the next line is empty.
|
||||
IFS=$'\n' read -r LINE
|
||||
if [ -n "${LINE}" ]; then
|
||||
exit 0
|
||||
fi
|
||||
done <<< "${COMMIT_DESC}"
|
||||
|
||||
echo "Commit description is not permitted."
|
||||
echo "${MESSAGE}"
|
||||
exit 1
|
||||
@@ -94,7 +94,10 @@ push to the source branch using the following command:
|
||||
|
||||
git push --force-with-lease origin ${source}
|
||||
|
||||
Remember to navigate back to your previous branch after pushing.
|
||||
Remember to navigate back to your previous branch after pushing. You
|
||||
may also want to delete the branch after the commit has been pushed.
|
||||
|
||||
git branch -D ${source}
|
||||
----------------------------------------------------------------------
|
||||
EOF
|
||||
else
|
||||
@@ -108,7 +111,10 @@ git fetch ${remote}
|
||||
git push --force-with-lease ${remote} ${source}
|
||||
git remote remove ${remote}
|
||||
|
||||
Remember to navigate back to your previous branch after pushing.
|
||||
Remember to navigate back to your previous branch after pushing. You
|
||||
may also want to delete the branch after the commit has been pushed.
|
||||
|
||||
git branch -D ${source}
|
||||
----------------------------------------------------------------------
|
||||
EOF
|
||||
fi
|
||||
|
||||
31
bin/rename/definitions.sh
Executable file
31
bin/rename/definitions.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script renames definitions, such as include guards, in this project.
|
||||
# Specifically, it renames "RIPPLED_XXX" and "RIPPLE_XXX" to "XRPL_XXX" by
|
||||
# scanning all cmake, header, and source files in the specified directory and
|
||||
# its subdirectories.
|
||||
# Usage: bin/rename/definitions.sh <directory>
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: $0 <directory>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIRECTORY=$1
|
||||
echo "Processing directory: ${DIRECTORY}"
|
||||
if [ ! -d "${DIRECTORY}" ]; then
|
||||
echo "Error: Directory '${DIRECTORY}' does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
find "${DIRECTORY}" -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.ipp" -o -name "*.cpp" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
sed -i'.bak' -E 's@#(define|endif|if|ifdef|ifndef)(.*)(RIPPLED_|RIPPLE_)([A-Z0-9_]+)@#\1\2XRPL_\4@g' "${FILE}"
|
||||
rm "${FILE}.bak"
|
||||
done
|
||||
find "${DIRECTORY}" -type f \( -name "*.cmake" -o -name "*.txt" \) | while read -r FILE; do
|
||||
echo "Processing file: ${FILE}"
|
||||
sed -i'.bak' -E 's@(RIPPLED_|RIPPLE_)([A-Z0-9_]+)@XRPL_\2@g' "${FILE}"
|
||||
rm "${FILE}.bak"
|
||||
done
|
||||
echo "Renaming complete."
|
||||
Reference in New Issue
Block a user