From a51ab8a54b1289b3be0d8e7ce9c2226721c1ef28 Mon Sep 17 00:00:00 2001 From: Jesse Rosenstock Date: Mon, 9 Nov 2026 05:52:42 -0800 Subject: [PATCH] ci: Reject placeholder internal-only commit messages Copybara exports from Google's internal repository require a public commit description, or fall back to a placeholder when none is provided. Authors also sometimes write a boilerplate placeholder when they expect a change not to be exported, and if the change touches an exported file anyway, that placeholder lands in the git history. Fail the `pre-commit` workflow if the commit message contains one of those placeholder phrases. Fetch depth 2 in `actions/checkout` so that `pull_request` runs can inspect `pull_request.head.sha` rather than GitHub's synthetic merge commit (`Merge into `), while still running `pre-commit` on the merged tree. PiperOrigin-RevId: 1017279458 --- .github/workflows/pre-commit.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index bce0548..00ca550 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -24,6 +24,24 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 + with: + # On pull_request events, actions/checkout checks out GitHub's + # synthetic merge commit (refs/pull//merge), whose message is + # "Merge into ". Depth 2 also fetches its parents so that + # pull_request.head.sha can be inspected below while pre-commit still + # runs on the merged tree. + fetch-depth: 2 + - name: Check commit message + env: + COMMIT_SHA: ${{github.event.pull_request.head.sha || 'HEAD'}} + run: | + # Fail if the commit message looks like an internal-only or placeholder + # description that should not have been exported via Copybara. + if git log -1 --format=%B "${COMMIT_SHA}" | grep -iqE 'internal change|automated code change|no public description'; then + echo "::error::Commit message contains a forbidden phrase ('internal change', 'automated code change', or 'No public description')." + echo "This commit either should not have been exported or needs a real public description." + exit 1 + fi - uses: actions/setup-python@v7 - uses: pre-commit/action@v3.0.1 with: