File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,8 +30,14 @@ git subtree split --prefix=packages/webentor-core -b split/webentor-core-mirror
3030
3131MIRROR_URL=" https://x-access-token:${CORE_MIRROR_TOKEN} @github.com/${CORE_MIRROR_REPO} .git"
3232
33- # Force-with-lease protects against clobbering unexpected remote state changes.
34- git push " $MIRROR_URL " split/webentor-core-mirror:main --force-with-lease
33+ # Query mirror remote state and use an explicit lease against its current main tip.
34+ REMOTE_MAIN_SHA=" $( git ls-remote --heads " $MIRROR_URL " main | awk ' {print $1}' ) "
35+ if [ -n " $REMOTE_MAIN_SHA " ]; then
36+ git push " $MIRROR_URL " split/webentor-core-mirror:main --force-with-lease=" main:${REMOTE_MAIN_SHA} "
37+ else
38+ # First mirror run can target repos where main does not exist yet.
39+ git push " $MIRROR_URL " split/webentor-core-mirror:main --force
40+ fi
3541git push " $MIRROR_URL " " split/webentor-core-mirror:refs/tags/${TAG} " --force
3642
3743echo " Mirrored packages/webentor-core to ${CORE_MIRROR_REPO} with tag ${TAG} ."
Original file line number Diff line number Diff line change @@ -29,7 +29,14 @@ git subtree split --prefix=packages/webentor-setup -b split/webentor-setup-mirro
2929
3030MIRROR_URL=" https://x-access-token:${SETUP_MIRROR_TOKEN} @github.com/${SETUP_MIRROR_REPO} .git"
3131
32- git push " $MIRROR_URL " split/webentor-setup-mirror:main --force-with-lease
32+ # Query mirror remote state and use an explicit lease against its current main tip.
33+ REMOTE_MAIN_SHA=" $( git ls-remote --heads " $MIRROR_URL " main | awk ' {print $1}' ) "
34+ if [ -n " $REMOTE_MAIN_SHA " ]; then
35+ git push " $MIRROR_URL " split/webentor-setup-mirror:main --force-with-lease=" main:${REMOTE_MAIN_SHA} "
36+ else
37+ # First mirror run can target repos where main does not exist yet.
38+ git push " $MIRROR_URL " split/webentor-setup-mirror:main --force
39+ fi
3340git push " $MIRROR_URL " " split/webentor-setup-mirror:refs/tags/${TAG} " --force
3441
3542echo " Mirrored packages/webentor-setup to ${SETUP_MIRROR_REPO} with tag ${TAG} ."
Original file line number Diff line number Diff line change @@ -29,7 +29,14 @@ git subtree split --prefix=packages/webentor-starter -b split/webentor-starter-m
2929
3030MIRROR_URL=" https://x-access-token:${STARTER_MIRROR_TOKEN} @github.com/${STARTER_MIRROR_REPO} .git"
3131
32- git push " $MIRROR_URL " split/webentor-starter-mirror:main --force-with-lease
32+ # Query mirror remote state and use an explicit lease against its current main tip.
33+ REMOTE_MAIN_SHA=" $( git ls-remote --heads " $MIRROR_URL " main | awk ' {print $1}' ) "
34+ if [ -n " $REMOTE_MAIN_SHA " ]; then
35+ git push " $MIRROR_URL " split/webentor-starter-mirror:main --force-with-lease=" main:${REMOTE_MAIN_SHA} "
36+ else
37+ # First mirror run can target repos where main does not exist yet.
38+ git push " $MIRROR_URL " split/webentor-starter-mirror:main --force
39+ fi
3340git push " $MIRROR_URL " " split/webentor-starter-mirror:refs/tags/${TAG} " --force
3441
3542echo " Mirrored packages/webentor-starter to ${STARTER_MIRROR_REPO} with tag ${TAG} ."
You can’t perform that action at this time.
0 commit comments