-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suggest clang-format changes on PRs (#499)
* Apply clang-format locally and suggest changes * Add executable permission to clang format apply
- Loading branch information
Showing
3 changed files
with
66 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
BASE_BRANCH=$1 | ||
CURRENT_BRANCH=$2 | ||
|
||
# Save unified diff with 0 context | ||
git diff -U0 --name-only $BASE_BRANCH...$CURRENT_BRANCH > filestochange.diff | ||
|
||
cat filestochange.diff | ||
|
||
# Run clang-format in-place on .h and .cpp files | ||
while IFS= read -r line; do | ||
if [ -n "$line" ]; then | ||
if [[ "$line" == *.h ]] || [[ "$line" == *.cpp ]]; then | ||
clang-format -i "$line" | ||
fi | ||
fi | ||
done < filestochange.diff | ||
|
||
rm filestochange.diff |