diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a005e6a802..7bf93e5996 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -409,3 +409,22 @@ jobs: node-version: 20.x - name: Check code style run: python ./ci/run_ci.py format + + cleanup_commit_message: + name: Cleanup commit message + runs-on: ubuntu-latest + if: ${{ github.event_name == 'pull_request' }} + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - name: Get last commit message + run: git --no-pager log -1 --pretty=%B > commit_msg.txt + + - name: Remove commented content from commit message + run: bash scripts/remove-commented-commit.sh commit_msg.txt + + - name: Show cleaned commit message + run: cat commit_msg.txt diff --git a/scripts/remove-commented-commit.sh b/scripts/remove-commented-commit.sh new file mode 100755 index 0000000000..ef060940d9 --- /dev/null +++ b/scripts/remove-commented-commit.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Script to remove commented content from git commit messages +# This ensures clean and readable commit history by filtering out +# lines starting with # or wrapped in + +# Read the commit message file +COMMIT_MSG_FILE=$1 + +if [ -z "$COMMIT_MSG_FILE" ]; then + echo "Error: No commit message file provided" + exit 1 +fi + +# Create a temporary file +TEMP_FILE=$(mktemp) + +# Remove commented lines and HTML comments +# - Lines starting with # (after optional whitespace) +# - HTML comment blocks +grep -v '^\s*#' "$COMMIT_MSG_FILE" | \ + sed '//d' > "$TEMP_FILE" + +# Replace original file with cleaned content +mv "$TEMP_FILE" "$COMMIT_MSG_FILE" +#test + +exit 0