better commit hash handling
This commit is contained in:
+27
-7
@@ -44,13 +44,33 @@ if [ "$COMMIT" == "$(git rev-parse --short HEAD)" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if the commit has been pushed
|
check_remote_commit_exists() {
|
||||||
REMOTE_COMMIT=$(git ls-remote https://github.com/jkiesele/minicalosim | grep $COMMIT)
|
# Usage: check_remote_commit_exists <repo-url> <commit-sha>
|
||||||
if [ -z "$REMOTE_COMMIT" ]; then
|
local url="$1"
|
||||||
echo "ERROR: Commit $COMMIT not found in remote repository."
|
local commit="$2"
|
||||||
echo only found commits:
|
|
||||||
git ls-remote https://github.com/jkiesele/minicalosim
|
# Create a temporary directory for a shallow fetch
|
||||||
exit 1
|
local tmpdir
|
||||||
|
tmpdir="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$tmpdir"' RETURN # auto-cleanup on function exit
|
||||||
|
|
||||||
|
git -C "$tmpdir" init -q
|
||||||
|
git -C "$tmpdir" remote add origin "$url"
|
||||||
|
|
||||||
|
if git -C "$tmpdir" fetch --quiet --depth=1 origin "$commit" 2>/dev/null; then
|
||||||
|
echo "✅ Commit $commit exists on remote."
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "❌ ERROR: Commit $commit not found on remote."
|
||||||
|
echo "Refs currently visible on remote:"
|
||||||
|
git ls-remote --heads --tags "$url"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# check if the commit has been pushed
|
||||||
|
if ! check_remote_commit_exists https://github.com/jkiesele/minicalosim $COMMIT; then
|
||||||
|
echo "ERROR: Commit $COMMIT not found in remote repository."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# check if no-cache is given as second argument
|
# check if no-cache is given as second argument
|
||||||
|
|||||||
Reference in New Issue
Block a user