Skip to content

Commit 4c95ae3

Browse files
committed
New script
1 parent 9685552 commit 4c95ae3

File tree

1 file changed

+21
-34
lines changed

1 file changed

+21
-34
lines changed

scripts/diffuse.sh

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -226,25 +226,24 @@ clone_repo() {
226226

227227
# After cloning from local repo, we need to fetch from the actual remote origin
228228
# to ensure all remote branches are properly available
229-
(cd "$clone_dir" && {
230-
# Get the actual remote origin URL from the source repo
231-
ACTUAL_ORIGIN=$(cd "$REPO_PATH" && git remote get-url origin 2>/dev/null || echo "")
232-
233-
if [ -n "$ACTUAL_ORIGIN" ]; then
234-
log_verbose "Fetching from actual remote origin: $ACTUAL_ORIGIN"
235-
# Update origin to point to the actual remote
236-
git remote set-url origin "$ACTUAL_ORIGIN" > /dev/null 2>&1 || true
237-
# Fetch all branches and tags from the actual remote
238-
git fetch origin --all --tags --prune > /dev/null 2>&1 || true
239-
else
240-
# Fallback: fetch from local repo
241-
git remote set-url origin "$repo_url" > /dev/null 2>&1 || true
242-
git fetch --all --tags --prune > /dev/null 2>&1 || true
243-
fi
244-
245-
# Also fetch tags directly
246-
git fetch origin "+refs/tags/*:refs/tags/*" > /dev/null 2>&1 || true
247-
})
229+
(
230+
cd "$clone_dir" || error_exit "Failed to enter clone dir for $label"
231+
232+
# Get the actual remote origin URL from the source repo
233+
ACTUAL_ORIGIN=$(cd "$REPO_PATH" && git remote get-url origin 2>/dev/null || echo "")
234+
235+
if [ -n "$ACTUAL_ORIGIN" ]; then
236+
log_verbose "Fetching from actual remote origin: $ACTUAL_ORIGIN"
237+
# Update origin to point to the actual remote
238+
git remote set-url origin "$ACTUAL_ORIGIN" > /dev/null 2>&1 || true
239+
else
240+
log_verbose "Using local repository as origin: $repo_url"
241+
git remote set-url origin "$repo_url" > /dev/null 2>&1 || true
242+
fi
243+
244+
# Fetch branches and tags for origin using default refspec
245+
git fetch origin --prune --tags > /dev/null 2>&1 || true
246+
)
248247

249248
log_verbose "✓ Repository cloned for $label"
250249
}
@@ -528,22 +527,10 @@ build_aar() {
528527
cd "$clone_dir" || error_exit "Failed to change to cloned repository directory"
529528

530529
# Verify ref exists (handles branches, tags, and commits)
531-
# First try to verify directly
530+
# At this point clone_repo has already fetched from origin, so the
531+
# ref should exist if it exists on the remote.
532532
if ! git rev-parse --verify "$ref" > /dev/null 2>&1; then
533-
# If that fails, try fetching the ref from origin
534-
log_verbose "Ref not found locally, attempting to fetch..."
535-
git fetch origin "$ref:$ref" > /dev/null 2>&1 || true
536-
# Also try fetching as a tag
537-
if [[ "$ref" =~ ^[0-9] ]]; then
538-
git fetch origin "refs/tags/$ref:refs/tags/$ref" > /dev/null 2>&1 || true
539-
fi
540-
# Try again
541-
if ! git rev-parse --verify "$ref" > /dev/null 2>&1; then
542-
# List available tags for debugging
543-
[ "$VERBOSE" = true ] && echo -e "${YELLOW}Available tags:${NC}"
544-
[ "$VERBOSE" = true ] && git tag | grep -E "^5\.[34]" | head -10 || git tag | tail -10
545-
error_exit "Ref does not exist: $ref (must be a branch, tag, or commit)"
546-
fi
533+
error_exit "Ref does not exist in cloned repo: $ref (ensure this branch/tag/SHA exists on origin)"
547534
fi
548535

549536
# Checkout the ref (works for branches, tags, and commits)

0 commit comments

Comments
 (0)