Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use --depth on git fetch for PRs #453

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions libcheckout
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,24 @@ function checkout::refbased() {
retry git clone --depth "${SEMAPHORE_GIT_DEPTH}" "${SEMAPHORE_GIT_URL}" "${SEMAPHORE_GIT_DIR}"
cd "${SEMAPHORE_GIT_DIR}" || exit

if ! retry git fetch origin +"${SEMAPHORE_GIT_REF}": 2>/dev/null; then
echo "Revision: ${SEMAPHORE_GIT_SHA} not found .... Exiting"
return 1
else
# Try fetching refs/objects with a depth.
if retry git fetch --depth "${SEMAPHORE_GIT_DEPTH}" origin +"${SEMAPHORE_GIT_REF}": 2>/dev/null; then
git checkout -qf FETCH_HEAD
echo "HEAD is now at ${SEMAPHORE_GIT_SHA}"

return 0
fi

# Fetch with depth failed, fallback to not using a depth.
if retry git fetch origin +"${SEMAPHORE_GIT_REF}": 2>/dev/null; then
git checkout -qf FETCH_HEAD
echo "HEAD is now at ${SEMAPHORE_GIT_SHA}"

return 0
fi

echo "Revision: ${SEMAPHORE_GIT_SHA} not found .... Exiting"
return 1
fi

if [ "${SEMAPHORE_GIT_REF_TYPE:-""}" = "tag" ]; then
Expand Down
Loading