Skip to content

Commit

Permalink
Apply clang-format locally and suggest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
samjwu committed May 27, 2024
1 parent a1a36a8 commit 4667e2c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ jobs:
- name: Check Clang-Format on Diff
run: |
./clang-format-diff.sh ${{ github.base_ref }} ${{ github.ref }}
- name: Apply Clang-Format locally
run: |
./clang-format-apply.sh ${{ github.base_ref }} ${{ github.ref }}
- name: Suggest changes
uses: parkerbxyz/suggest-changes@v1
with:
comment: 'Please make the changes suggested by clang-format'
10 changes: 10 additions & 0 deletions clang-format-apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

BASE_BRANCH=$1
CURRENT_BRANCH=$2

# Save unified diff with 0 context
git diff -U0 --name-only $BASE_BRANCH...$CURRENT_BRANCH > changes.diff

# Apply clang-format on diff
FORMAT_DIFF=$(clang-format -i -style=file changes.diff)

0 comments on commit 4667e2c

Please sign in to comment.