Skip to content

Commit 4b113b6

Browse files
committed
git: Improve SHA fetching logic in entrypoint.sh
Enhance the script to fetch the specified SHA from both origin and fork remotes, ensuring better error handling and user feedback if the SHA is not found. Signed-off-by: Chiho Sin <[email protected]>
1 parent 7ab9197 commit 4b113b6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

entrypoint.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,23 @@ set -euo pipefail
1414
: "${CPY_DEBUG:=}"
1515
: "${CPY_TRANSLATION:=en_US}"
1616

17+
# Try fetching the SHA from both remotes
18+
if ! git rev-parse "${GITHUB_SHA}" >/dev/null 2>&1; then
19+
echo "SHA ${GITHUB_SHA} not found locally. Fetching from origin..."
20+
git fetch origin "${GITHUB_SHA}" --tags --prune || echo "SHA not found in origin."
21+
fi
22+
23+
if ! git rev-parse "${GITHUB_SHA}" >/dev/null 2>&1; then
24+
echo "SHA ${GITHUB_SHA} not found in origin. Fetching from fork..."
25+
git fetch fork "${GITHUB_SHA}" --tags --prune || echo "SHA not found in fork."
26+
fi
27+
28+
# Final check: If SHA still doesn't exist, fail
29+
if ! git rev-parse "${GITHUB_SHA}" >/dev/null 2>&1; then
30+
echo "Error: SHA ${GITHUB_SHA} not found in either remote."
31+
exit 1
32+
fi
33+
1734
git checkout "${GITHUB_SHA}"
1835
make -C ports/"${CPY_PLATFORM}" fetch-port-submodules
1936
pip3 install --upgrade -r requirements-dev.txt

0 commit comments

Comments
 (0)