[llvm] [Github] Set start rev to merge base in code format action (PR #75132)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 19:40:31 PST 2023


https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/75132

This patch sets the start revision to the merge base so that the c++ formatting action won't produce any diffs related to changes in main but not in the PR branch. This also leaves a TODO to migrate over to the --diff_from_common_commit option in git-clang-format once LLVM v18 is released.

>From a44cb6284ded09179de085d87ccfc1e7bceddd72 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <agrossman154 at yahoo.com>
Date: Mon, 11 Dec 2023 19:33:35 -0800
Subject: [PATCH] [Github] Set start rev to merge base in code format action

This patch sets the start revision to the merge base so that the c++
formatting action won't produce any diffs related to changes in main but
not in the PR branch. This also leaves a TODO to migrate over to the
--diff_from_common_commit option in git-clang-format once LLVM v18 is
released.
---
 .github/workflows/pr-code-format.yml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/pr-code-format.yml b/.github/workflows/pr-code-format.yml
index c27c282eb2a19a..5223089ee8a93d 100644
--- a/.github/workflows/pr-code-format.yml
+++ b/.github/workflows/pr-code-format.yml
@@ -67,10 +67,14 @@ jobs:
           START_REV: ${{ github.event.pull_request.base.sha }}
           END_REV: ${{ github.event.pull_request.head.sha }}
           CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
+        # TODO(boomanaiden154): Once clang v18 is released, we should be able
+        # to take advantage of the new --diff_from_common_commit option
+        # explicitly in code-format-helper.py and not have to diff starting at
+        # the merge base.
         run: |
           python ./code-format-tools/llvm/utils/git/code-format-helper.py \
             --token ${{ secrets.GITHUB_TOKEN }} \
             --issue-number $GITHUB_PR_NUMBER \
-            --start-rev $START_REV \
+            --start-rev $(git merge-base $START_REV $END_REV) \
             --end-rev $END_REV \
             --changed-files "$CHANGED_FILES"



More information about the llvm-commits mailing list