Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: improvement of clang-format step #17617

Merged
merged 5 commits into from
Feb 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .ci/format_script.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env bash

set -ex

echo "Running clang-format against branch $TRAVIS_BRANCH, with hash $BASE_COMMIT"
clang-format --version
COMMIT_FILES=$(git diff --name-status $BASE_COMMIT | grep -i -v '.mjs$' | grep -i -v LinkDef | grep -v -E '^D +' | sed -E 's,^.[[:space:]]+,,')

RESULT_OUTPUT="no modified files to format"
Expand All @@ -18,16 +17,16 @@ if [ "$RESULT_OUTPUT" == "no modified files to format" ] \
echo "clang-format passed."
exit 0
else
echo "clang-format failed."
echo "To reproduce it locally please run"
echo -e "\tgit checkout $TRAVIS_PULL_REQUEST_BRANCH"
echo -e "\tgit-clang-format --commit $BASE_COMMIT --diff --binary $(which clang-format)"
echo -e "clang-format failed with the following diff:\n"
echo "$RESULT_OUTPUT"

echo -e "\n\nPlease apply the code formatting changes without bloating the history."
echo -e "\tConsider running:"
echo -e "\nTo reproduce it locally please run"
echo -e "\tgit checkout $TRAVIS_PULL_REQUEST_BRANCH"
echo -e "\tgit-clang-format --commit $BASE_COMMIT --diff --binary $(which clang-format) # adjust to point to the local clang-format"

echo -e "\nConsider running the following to apply the code formatting changes without bloating the history."
echo -e "\t\tgit checkout $TRAVIS_PULL_REQUEST_BRANCH"
echo -e "\t\tgit rebase -i -x \"git-clang-format-7 master && git commit -a --allow-empty --fixup=HEAD\" --strategy-option=theirs origin/master"
echo -e "\t\tgit rebase -i -x \"git-clang-format master && git commit -a --allow-empty --fixup=HEAD\" --strategy-option=theirs origin/master"
echo -e "\t Then inspect the results with git log --oneline"
echo -e "\t Then squash without poluting the history with: git rebase --autosquash -i master"

Expand Down
Loading