Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a new CI step to detect raw issue references in commit messages #3255

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/commit-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,33 @@ jobs:
done < <(git rev-list --reverse "$rev_list" )

exit $retval;

check-issue-reference:
runs-on: ubuntu-latest
continue-on-error: true # We do not want to block merge if it is a legitimate GCC bugzilla reference.
name: check-issue-reference

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Check for issue number reference in commit messages
run: |
retval=0;
rev_list="origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}"
for commit in $(git rev-list --reverse "$rev_list"); do
if [ "$(git log --format=%B -n 1 \"$commit\" | grep '#[0-9]*' | grep -v -i 'Rust-GCC/gccrs#[0-9]*' | wc -l)" -ne 0 ]; then
echo "$commit: KO"
retval=1
else
echo "$commit: OK"
fi
done;
if [ "$retval" -ne 0 ]; then
echo "Some raw issue references were found (eg. #4242)."
echo "You shall rewrite the faulty commit message with this format: Rust-GCC/gccrs#4242"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "You shall rewrite the faulty commit message with this format: Rust-GCC/gccrs#4242"
echo "Rewrite the faulty commit message with this format: Rust-GCC/gccrs#4242"

echo "You may ignore this CI step if it represents a valid GCC bugzilla or external repository reference instead."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "You may ignore this CI step if it represents a valid GCC bugzilla or external repository reference instead."
echo "You may ignore this CI step if it represents a valid GCC bugzilla reference instead."

fi
exit $retval;
Loading