Skip to content

Commit e52b895

Browse files
EtiennePerotgvisor-bot
authored andcommitted
PGO: Skip PGO update branch creation if it already exists.
PiperOrigin-RevId: 772605144
1 parent 89dbb7b commit e52b895

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

.buildkite/scripts/pgo/commit-update.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ if [[ "$(git status --porcelain | wc -l)" == 0 ]]; then
2222
fi
2323

2424
today="$(date +"%Y-%m-%d")"
25+
repo_url="https://github.com/google/gvisor.git"
2526
pgo_branch_name="pgo/update-${today}"
27+
existing_remote="$(git ls-remote --heads "$repo_url" "refs/heads/${pgo_branch_name}" || true)"
28+
if [[ -n "$existing_remote" ]]; then
29+
echo "Remote branch '$pgo_branch_name' already exists, skipping." >&2
30+
exit 0
31+
fi
2632
git stash
27-
git pull --rebase=true https://github.com/google/gvisor master
33+
git pull --rebase=true "$repo_url" master
2834
git checkout -b "$pgo_branch_name"
2935
git stash pop
3036
git add runsc/profiles
@@ -37,7 +43,7 @@ export GIT_AUTHOR_EMAIL=gvisor-bot@google.com
3743
export GIT_COMMITTER_NAME=gvisor-bot
3844
export GIT_COMMITTER_EMAIL=gvisor-bot@google.com
3945
git commit -m "Update runsc profiles for PGO (profile-guided optimizations), $today."
40-
git push --set-upstream https://github.com/google/gvisor.git "$pgo_branch_name"
46+
git push --set-upstream "$repo_url" "$pgo_branch_name"
4147

4248
# The 'yes' command will fail when the `gh` command closes its stdin,
4349
# which the `pipefail` option treats as a total failure.

0 commit comments

Comments
 (0)