Skip to content

Commit

Permalink
use pre-commit to run dev tools scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelKoch committed Nov 27, 2023
1 parent c7ad92f commit 9632f4f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 0 additions & 2 deletions .github/format-rebase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ DIFF_COMMAND="git diff --name-only --no-renames --diff-filter=AM HEAD~ | grep -E
git rebase --rebase-merges --empty=drop --no-keep-empty \
--exec "cp /tmp/.clang-format /tmp/.pre-commit-config.yaml . && \
cp /tmp/format_header.sh /tmp/update_ginkgo_header.sh dev_tools/scripts/ && \
dev_tools/scripts/update_ginkgo_header.sh && \
for f in \$($DIFF_COMMAND | grep -E '$FORMAT_HEADER_REGEX'); do dev_tools/scripts/format_header.sh \$f; done && \
git add .pre-commit-config.yaml && \
pipx run pre-commit run && \
git restore --staged .pre-commit-config.yaml && \
Expand Down
13 changes: 3 additions & 10 deletions .github/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@
cp .github/bot-pr-format-base.sh /tmp
source /tmp/bot-pr-format-base.sh

echo "Retrieving PR file list"
PR_FILES=$(bot_get_all_changed_files ${PR_URL})
NUM=$(echo "${PR_FILES}" | wc -l)
echo "PR has ${NUM} changed files"

TO_FORMAT="$(echo "$PR_FILES" | grep -E $EXTENSION_REGEX || true)"

# format files
dev_tools/scripts/update_ginkgo_header.sh
for f in $(echo "$TO_FORMAT" | grep -E $FORMAT_HEADER_REGEX); do dev_tools/scripts/format_header.sh "$f"; done
pipx run pre-commit run --files $TO_FORMAT || true
echo "Formatting files"

pipx run pre-commit run --from-ref "origin/$BASE_BRANCH" --to-ref HEAD || true

# restore formatting scripts so they don't appear in the diff
git restore --staged .pre-commit-config.yaml
Expand Down

0 comments on commit 9632f4f

Please sign in to comment.