From 52f1dd5e7270dd78ae4ae246d583f2f7c6df0ba5 Mon Sep 17 00:00:00 2001 From: Ayush Ranjan Date: Thu, 29 Oct 2020 15:04:56 -0700 Subject: [infra] Deflake Go / generate (pull_request. #4673 does not seem to work. Try this new approach. PiperOrigin-RevId: 339754794 --- tools/go_branch.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'tools/go_branch.sh') diff --git a/tools/go_branch.sh b/tools/go_branch.sh index 100c4ae41..9ce573872 100755 --- a/tools/go_branch.sh +++ b/tools/go_branch.sh @@ -61,14 +61,6 @@ go_branch=$( \ ) readonly go_branch -declare commit -commit=$(git rev-parse HEAD) -readonly commit -if [[ -n "$(git branch --contains="${commit}" go)" ]]; then - # The go branch already has the commit. - exit 0 -fi - # Clone the current repository to the temporary directory, and check out the # current go_branch directory. We move to the new repository for convenience. declare repo_orig @@ -130,7 +122,11 @@ find . -type f -exec chmod 0644 {} \; find . -type d -exec chmod 0755 {} \; # Update the current working set and commit. -git add . && git commit -m "Merge ${head} (automated)" +# If the current working commit has already been committed to the remote go +# branch, then we have nothing to commit here. So allow empty commit. This can +# occur when this script is run parallely (via pull_request and push events) +# and the push workflow finishes before the pull_request workflow can run this. +git add . && git commit --allow-empty -m "Merge ${head} (automated)" # Push the branch back to the original repository. git remote add orig "${repo_orig}" && git push -f orig go:go -- cgit v1.2.3