@@ -86,12 +86,26 @@ jobs:
8686 git init "$GITHUB_WORKSPACE"
8787 git -C "$GITHUB_WORKSPACE" config gc.auto 0
8888 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git"
89- if ! git -C "$GITHUB_WORKSPACE" fetch --no-tags --depth=1 origin "+${CHECKOUT_REF}:refs/remotes/origin/checkout"; then
89+ fetch_checkout_ref() {
90+ local ref="$1"
91+ timeout --signal=TERM --kill-after=10s 30s git -C "$GITHUB_WORKSPACE" \
92+ -c protocol.version=2 \
93+ fetch --no-tags --prune --no-recurse-submodules --depth=1 origin \
94+ "+${ref}:refs/remotes/origin/checkout"
95+ }
96+ if fetch_checkout_ref "$CHECKOUT_REF"; then
97+ :
98+ else
99+ fetch_status="$?"
100+ if [ "$fetch_status" = "124" ] || [ "$fetch_status" = "137" ]; then
101+ echo "::error::checkout fetch for '$CHECKOUT_REF' timed out"
102+ exit "$fetch_status"
103+ fi
90104 if [ "$GITHUB_EVENT_NAME" != "workflow_dispatch" ] || [ "$CHECKOUT_REF" = "$CHECKOUT_FALLBACK_REF" ]; then
91- exit 1
105+ exit "$fetch_status"
92106 fi
93107 echo "::warning::workflow_dispatch target_ref '$CHECKOUT_REF' is unavailable; falling back to head SHA '$CHECKOUT_FALLBACK_REF'"
94- git -C "$GITHUB_WORKSPACE" fetch --no-tags --depth=1 origin "+${ CHECKOUT_FALLBACK_REF}:refs/remotes/origin/checkout "
108+ fetch_checkout_ref "$ CHECKOUT_FALLBACK_REF"
95109 fi
96110 git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
97111
@@ -321,12 +335,26 @@ jobs:
321335 git init "$GITHUB_WORKSPACE"
322336 git -C "$GITHUB_WORKSPACE" config gc.auto 0
323337 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git"
324- if ! git -C "$GITHUB_WORKSPACE" fetch --no-tags --depth=1 origin "+${CHECKOUT_REF}:refs/remotes/origin/checkout"; then
338+ fetch_checkout_ref() {
339+ local ref="$1"
340+ timeout --signal=TERM --kill-after=10s 30s git -C "$GITHUB_WORKSPACE" \
341+ -c protocol.version=2 \
342+ fetch --no-tags --prune --no-recurse-submodules --depth=1 origin \
343+ "+${ref}:refs/remotes/origin/checkout"
344+ }
345+ if fetch_checkout_ref "$CHECKOUT_REF"; then
346+ :
347+ else
348+ fetch_status="$?"
349+ if [ "$fetch_status" = "124" ] || [ "$fetch_status" = "137" ]; then
350+ echo "::error::checkout fetch for '$CHECKOUT_REF' timed out"
351+ exit "$fetch_status"
352+ fi
325353 if [ "$GITHUB_EVENT_NAME" != "workflow_dispatch" ] || [ "$CHECKOUT_REF" = "$CHECKOUT_FALLBACK_REF" ]; then
326- exit 1
354+ exit "$fetch_status"
327355 fi
328356 echo "::warning::workflow_dispatch target_ref '$CHECKOUT_REF' is unavailable; falling back to head SHA '$CHECKOUT_FALLBACK_REF'"
329- git -C "$GITHUB_WORKSPACE" fetch --no-tags --depth=1 origin "+${ CHECKOUT_FALLBACK_REF}:refs/remotes/origin/checkout "
357+ fetch_checkout_ref "$ CHECKOUT_FALLBACK_REF"
330358 fi
331359 git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
332360
@@ -1555,7 +1583,10 @@ jobs:
15551583 git init "$GITHUB_WORKSPACE"
15561584 git -C "$GITHUB_WORKSPACE" config gc.auto 0
15571585 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git"
1558- git -C "$GITHUB_WORKSPACE" fetch --no-tags --depth=1 origin "+${CHECKOUT_SHA}:refs/remotes/origin/checkout"
1586+ timeout --signal=TERM --kill-after=10s 30s git -C "$GITHUB_WORKSPACE" \
1587+ -c protocol.version=2 \
1588+ fetch --no-tags --prune --no-recurse-submodules --depth=1 origin \
1589+ "+${CHECKOUT_SHA}:refs/remotes/origin/checkout"
15591590 git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
15601591
15611592 - name : Setup Python
@@ -1603,7 +1634,27 @@ jobs:
16031634 git init "$GITHUB_WORKSPACE"
16041635 git -C "$GITHUB_WORKSPACE" config gc.auto 0
16051636 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git"
1606- git -C "$GITHUB_WORKSPACE" fetch --no-tags --depth=1 origin "+${CHECKOUT_SHA}:refs/remotes/origin/checkout"
1637+ fetch_checkout_ref() {
1638+ git -C "$GITHUB_WORKSPACE" \
1639+ -c protocol.version=2 \
1640+ fetch --no-tags --prune --no-recurse-submodules --depth=1 origin \
1641+ "+${CHECKOUT_SHA}:refs/remotes/origin/checkout" &
1642+ local fetch_pid="$!"
1643+ local elapsed=0
1644+ while kill -0 "$fetch_pid" 2>/dev/null; do
1645+ if [ "$elapsed" -ge 30 ]; then
1646+ kill -TERM "$fetch_pid" 2>/dev/null || true
1647+ sleep 10
1648+ kill -KILL "$fetch_pid" 2>/dev/null || true
1649+ wait "$fetch_pid" || true
1650+ return 124
1651+ fi
1652+ sleep 1
1653+ elapsed=$((elapsed + 1))
1654+ done
1655+ wait "$fetch_pid"
1656+ }
1657+ fetch_checkout_ref
16071658 git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
16081659
16091660 - name : Try to exclude workspace from Windows Defender (best-effort)
@@ -1703,7 +1754,27 @@ jobs:
17031754 git init "$GITHUB_WORKSPACE"
17041755 git -C "$GITHUB_WORKSPACE" config gc.auto 0
17051756 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git"
1706- git -C "$GITHUB_WORKSPACE" fetch --no-tags --depth=1 origin "+${CHECKOUT_SHA}:refs/remotes/origin/checkout"
1757+ fetch_checkout_ref() {
1758+ git -C "$GITHUB_WORKSPACE" \
1759+ -c protocol.version=2 \
1760+ fetch --no-tags --prune --no-recurse-submodules --depth=1 origin \
1761+ "+${CHECKOUT_SHA}:refs/remotes/origin/checkout" &
1762+ local fetch_pid="$!"
1763+ local elapsed=0
1764+ while kill -0 "$fetch_pid" 2>/dev/null; do
1765+ if [ "$elapsed" -ge 30 ]; then
1766+ kill -TERM "$fetch_pid" 2>/dev/null || true
1767+ sleep 10
1768+ kill -KILL "$fetch_pid" 2>/dev/null || true
1769+ wait "$fetch_pid" || true
1770+ return 124
1771+ fi
1772+ sleep 1
1773+ elapsed=$((elapsed + 1))
1774+ done
1775+ wait "$fetch_pid"
1776+ }
1777+ fetch_checkout_ref
17071778 git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
17081779
17091780 - name : Setup Node environment
@@ -1749,7 +1820,27 @@ jobs:
17491820 git init "$GITHUB_WORKSPACE"
17501821 git -C "$GITHUB_WORKSPACE" config gc.auto 0
17511822 git -C "$GITHUB_WORKSPACE" remote add origin "https://github.com/${CHECKOUT_REPO}.git"
1752- git -C "$GITHUB_WORKSPACE" fetch --no-tags --depth=1 origin "+${CHECKOUT_SHA}:refs/remotes/origin/checkout"
1823+ fetch_checkout_ref() {
1824+ git -C "$GITHUB_WORKSPACE" \
1825+ -c protocol.version=2 \
1826+ fetch --no-tags --prune --no-recurse-submodules --depth=1 origin \
1827+ "+${CHECKOUT_SHA}:refs/remotes/origin/checkout" &
1828+ local fetch_pid="$!"
1829+ local elapsed=0
1830+ while kill -0 "$fetch_pid" 2>/dev/null; do
1831+ if [ "$elapsed" -ge 30 ]; then
1832+ kill -TERM "$fetch_pid" 2>/dev/null || true
1833+ sleep 10
1834+ kill -KILL "$fetch_pid" 2>/dev/null || true
1835+ wait "$fetch_pid" || true
1836+ return 124
1837+ fi
1838+ sleep 1
1839+ elapsed=$((elapsed + 1))
1840+ done
1841+ wait "$fetch_pid"
1842+ }
1843+ fetch_checkout_ref
17531844 git -C "$GITHUB_WORKSPACE" checkout --detach refs/remotes/origin/checkout
17541845
17551846 - name : Install XcodeGen / SwiftLint / SwiftFormat
0 commit comments