| #!/bin/bash |
| |
| # Copyright 2020 Google LLC |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| set -e -x |
| |
| WORKING_BRANCH=synth-update |
| |
| cd $(dirname $0)/../../.. |
| |
| should_create_pr=1 |
| git checkout -b $WORKING_BRANCH || { |
| # The branch already exists - assume there's an existing PR. |
| unset should_create_pr; |
| |
| # Reset back to master |
| git checkout $WORKING_BRANCH; |
| git reset --hard origin/master; |
| } |
| |
| pushd google-api-go-generator |
| make all |
| popd |
| |
| if [[ -z "$(git status --porcelain)"]]; then |
| echo "No changes today; exiting." |
| exit 0; |
| fi |
| |
| echo "Pushing changes" |
| |
| commit_message="all: autogenerated update ($(date '+%Y-%m-%d'))" |
| git commit --all -m "$commit_message" |
| |
| git push origin $WORKING_BRANCH:$WORKING_BRANCH -f |
| |
| if [ "$should_create_pr" ]; then |
| echo "Creating PR." |
| go run ./sendpr -title "$commit_message" |
| fi |
| |