From 4a063913d4c6bac9ec422951e71378990f8d1773 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sat, 23 Dec 2023 18:32:49 +0100 Subject: [PATCH] wait until the repository is updated when pushing as it indicates the push event was processed Fixes: https://code.forgejo.org/actions/cascading-pr/issues/13 --- cascading-pr.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cascading-pr.sh b/cascading-pr.sh index d45c9df..9c0e768 100755 --- a/cascading-pr.sh +++ b/cascading-pr.sh @@ -33,6 +33,13 @@ function default_branch() { jq --raw-output .default_branch < $TMPDIR/$direction.json } +function updated_at() { + local direction=$1 + + repo_curl ${options[${direction}_repo]} api_json ${options[${direction}_api]} > $TMPDIR/$direction.json + jq --raw-output .updated_at < $TMPDIR/$direction.json +} + function exists_branch() { local direction=$1 @@ -218,8 +225,10 @@ function push() { cd $TMPDIR/$direction git add . if git commit -m 'cascading-pr update'; then + local updated_at=$(updated_at $direction) git push --force ${remote} prbranch:$branch git rev-parse HEAD > ../$direction.sha + retry test "$updated_at" != "$(updated_at $direction)" log_info "pushed" else log_info "nothing to push"