gorgeous-winter-99296
10/15/2023, 9:14 PMgorgeous-winter-99296
10/15/2023, 9:14 PMHello and thanks for the pull request!
We have recently (#PR_NO) removed our custom formatting for Rust to follow the rest of the community. Unfortunately your PR got caught in-between, and needs some extra work to be mergeable. We have a helper script (ADD LINK) you can copy to the repository root which will hopefully make it a bit easier and safer (to get started). You can of course also use your preferred method of rebase/merge get updated.reformat-helper.sh sync
Feel free to ping ping @tgolsson/Tom Solberg on Slack for assistance.
gorgeous-winter-99296
10/15/2023, 9:14 PM# CONSTANTS, known once PR is merged
WITH_NEW_SETTINGS_COMMIT=364d675f20a558f7ba4670addc4adc09d3190c66
WITH_NEW_FORMAT_COMMIT=d9bdd80810b0384de455b955d3fa530d936d9f93
if [ "$#" -ne 1 ]; then
echo "Error: Expected a single command, 'sync' or 'reformat'"
exit 1
fi
if [ "$1" != "sync" ] && [ "$1" != "reformat" ]; then
echo "Error: Expected 'sync' or 'reformat', found '$1'"
exit 1
fi
if [ "$1" = "sync" ]; then
echo "This script will update the current branch to the last commit before the Pants codebase was reformatted. This script uses \`git rebase\`, which can be hard to debug and recover from if things go wrong."
while true; do
read -p "Do you wish to proceed?" yn
case $yn in
[Yy]* ) make install; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
branch_name=$(git branch --show-current)
git branch "$branch_name-backup" "$branch_name"
git fetch <https://github.com/pantsbuild/pants> main
BASE_SHA=$(git merge-base HEAD $WITH_NEW_SETTINGS_COMMIT)
git rebase --onto "$WITH_NEW_SETTINGS_COMMIT" "$BASE_SHA"
echo "Rebased '$branch_name' on last pre-format main '$WITH_NEW_SETTINGS_COMMIT'."
echo "The old state is backed up as '$branch_name-backup'."
echo "If your \`git status\` is OK, you can proceed directly with \`$0 reformat\`."
echo "Otherwise, finish the rebase and commit as usual, before continuing with the \`reformat\` step."
exit 0
fi
if [ "$1" = "reformat" ]; then
echo "This script will update the current branch to the commit after the Pants codebase was reformatted. This step similarly uses \`git rebase\`, with the same caveats. Note that this step is likely to break if you have not first run \`$0 sync\`."
while true; do
read -p "Do you wish to proceed?" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
# Since Pants doesn't use a workspace; this is a hacky way to hopefully catch most code.
git rebase \
--strategy-option theirs \
--empty=drop \
--exec 'cargo fmt --all --manifest-path src/rust/engine/Cargo.toml || echo "failed formatting but continuing"; cargo fmt --all --manifest-path src/rust/engine/client/Cargo.toml || echo "failed formatting but continuing" ; cargo fmt --all --manifest-path src/rust/engine/fs/brfs/Cargo.toml || echo "failed formatting but continuing" ; cargo fmt --all --manifest-path src/rust/engine/fs/fs_util/Cargo.toml || echo "failed formatting but continuing" ; cargo fmt --all --manifest-path src/rust/engine/process_executor/Cargo.toml || echo "failed formatting but continuing" ; cargo fmt --all --manifest-path src/rust/engine/testutil/local_cas/Cargo.toml || echo "failed formatting but continuing" ; cargo fmt --all --manifest-path src/rust/engine/testutil/local_execution_server/Cargo.toml || echo "failed formatting but continuing" ; git add src/rust && git commit --amend --no-verify --no-edit' \
--onto $WITH_NEW_FORMAT_COMMIT $WITH_NEW_SETTINGS_COMMIT;
echo "Reformatting done. Please push your branch with \`--force-with-lease\` and re-request reviews."
exit 0
fihundreds-father-404
10/15/2023, 9:16 PMbitter-ability-32190
10/15/2023, 10:21 PMbitter-ability-32190
10/15/2023, 10:21 PMbitter-ability-32190
10/15/2023, 10:22 PMgorgeous-winter-99296
10/16/2023, 1:15 PM.git-blame-ignore-revs as a follow-up, so the PR doesn't depend on the sha of one of its own commits.