Skip to content

Commit f13068b

Browse files
TimoWilkendavidrohr
authored andcommitted
Fix code formatting workflows
If there are no files to process, don't fail, and make sure to mark the PR as "clean".
1 parent 9658519 commit f13068b

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

.github/workflows/code-formatting.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ jobs:
4747
# the branch we are merging into.
4848
BASE_COMMIT=$(git merge-base HEAD ${{ github.event.pull_request.base.sha }})
4949
echo "Running clang-format against branch ${{ github.event.pull_request.base.ref }}, with hash ${{ github.event.pull_request.base.sha }}"
50-
COMMIT_FILES=$(git diff --diff-filter d --name-only $BASE_COMMIT | grep -ivE 'LinkDef|Utilities/PCG/')
51-
[ "X$COMMIT_FILES" = X ] && { echo "No files to check" ; exit 0; }
50+
COMMIT_FILES=$(git diff --diff-filter d --name-only "$BASE_COMMIT" -- ':!*LinkDef*' ':!Utilities/PCG/')
51+
if [ -z "$COMMIT_FILES" ]; then
52+
echo "No files to check" >&2
53+
echo ::set-output name=clean::true
54+
exit 0
55+
fi
5256
RESULT_OUTPUT="$(git-clang-format --commit $BASE_COMMIT --diff --style file $COMMIT_FILES)"
5357
5458
for x in $COMMIT_FILES; do

.github/workflows/code-transformations.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ jobs:
4242
BASE_COMMIT=$(git merge-base HEAD ${{ github.event.pull_request.base.sha }})
4343
echo "Running refactoring against branch ${{ github.event.pull_request.base.ref }}, with hash ${{ github.event.pull_request.base.sha }}"
4444
COMMIT_FILES=$(git diff --diff-filter d --name-only $BASE_COMMIT)
45-
[ "X$COMMIT_FILES" = X ] && { echo "No files to check" ; exit 0; }
45+
if [ -z "$COMMIT_FILES" ]; then
46+
echo "No files to check" >&2
47+
echo ::set-output name=clean::true
48+
exit 0
49+
fi
4650
perl -p -i -e "${{ env.REFACTORING }}" $COMMIT_FILES
47-
RESULT_OUTPUT="$(git diff)"
4851
4952
if git diff --exit-code; then
5053
echo "Refactoring not needed."

0 commit comments

Comments
 (0)