-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into cirq_google-restore-api.v2-protos
- Loading branch information
Showing
3 changed files
with
48 additions
and
75 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,47 @@ | ||
#!/usr/bin/env bash | ||
|
||
################################################################################ | ||
# Verifies that Python files generated from protobuf definitions are up to date. | ||
# | ||
# See dev_tools/build-protos.sh for building all protos. | ||
################################################################################ | ||
|
||
# Get the working directory to the repo root. | ||
thisdir="$(dirname "${BASH_SOURCE[0]}")" || exit $? | ||
topdir="$(git -C "${thisdir}" rev-parse --show-toplevel)" || exit $? | ||
cd "${topdir}" || exit $? | ||
|
||
git_status="$(git status --short)" | ||
if [[ -n "${git_status}" ]]; then | ||
echo "$0 requires a pristine worktree, but 'git status' shows" | ||
echo "some changes or untracked files." | ||
echo | ||
echo "Please commit or clean these up to try again." | ||
exit 2 | ||
fi | ||
|
||
echo "Removing generated Python files. If not restored by this script use" | ||
echo 'git restore "*_pb2.py*" to recover them back.' | ||
echo | ||
|
||
git rm --quiet "cirq-google/*_pb2.py*" | ||
# restore deleted files in git index | ||
git reset --quiet | ||
|
||
echo "Building protos in $PWD" | ||
echo | ||
|
||
dev_tools/build-protos.sh | ||
|
||
git_status="$(git status --short)" | ||
|
||
if [[ -n "${git_status}" ]]; then | ||
echo | ||
echo -e "\033[31mERROR: dev_tools/build-protos.sh changed generated files!\033[0m" | ||
echo -e "\033[31mPlease update and commit these files using dev_tools/build-protos.sh\033[0m" | ||
echo | ||
echo "Output of 'git status' (note there may be untracked new files or deleted old ones):" | ||
echo | ||
git status | ||
exit 1 | ||
fi |