@@ -37,47 +37,24 @@ repo_name=$(basename "$REPO_URL" .git)
3737# Initialize selected_branch
3838selected_branch=" "
3939
40- # If branch is specified, try cloning it first
40+ # Clone repository with defaut branch or specified branch
41+ echo " Cloning repository..."
4142if [ -n " $BRANCH " ]; then
42- echo " Trying to clone specified branch: $BRANCH "
43- if git clone --branch " $BRANCH " --depth 1000 " $REPO_URL " " $WORKDIR /$repo_name " 2> /dev/null; then
44- selected_branch=" $BRANCH "
45- echo " ✅ Successfully cloned branch: $BRANCH "
46- else
47- echo " Error: Failed to clone specified branch: $BRANCH " >&2
43+ if ! git clone --branch " $BRANCH " --depth 1000 " $REPO_URL " " $WORKDIR /$repo_name " 2> /dev/null; then
44+ echo " ❌ Error: Failed to clone specified branch: $BRANCH " >&2
4845 echo " Clone failed for $repo_name branch $BRANCH at $( date ' +%Y-%m-%d %H:%M:%S %Z' ) " > " $OUTPUT_DIR /bugspots-${repo_name} .err"
4946 exit 1
5047 fi
48+ selected_branch=" $BRANCH "
49+ echo " ✅ Successfully cloned branch: $BRANCH "
5150else
52- # Try default branches in order of preference (master first to match bugspots default)
53- branches=(" master" " main" )
54- clone_success=false
55-
56- for branch in " ${branches[@]} " ; do
57- echo " Trying to clone branch: $branch "
58- if git clone --branch " $branch " --depth 1000 " $REPO_URL " " $WORKDIR /$repo_name " 2> /dev/null; then
59- clone_success=true
60- selected_branch=" $branch "
61- echo " ✅ Successfully cloned branch: $branch "
62- break
63- fi
64- done
65-
66- # If named branches fail, try default clone
67- if [ " $clone_success " = false ]; then
68- echo " Named branches failed, trying default clone..."
69- if git clone --depth 1000 " $REPO_URL " " $WORKDIR /$repo_name " ; then
70- clone_success=true
71- selected_branch=$( git -C " $WORKDIR /$repo_name " rev-parse --abbrev-ref HEAD)
72- echo " ✅ Successfully cloned with default branch: $selected_branch "
73- fi
74- fi
75-
76- if [ " $clone_success " = false ]; then
51+ if ! git clone --depth 1000 " $REPO_URL " " $WORKDIR /$repo_name " 2> /dev/null; then
7752 echo " Error: Failed to clone $REPO_URL " >&2
7853 echo " Clone failed for $repo_name at $( date ' +%Y-%m-%d %H:%M:%S %Z' ) " > " $OUTPUT_DIR /bugspots-${repo_name} .err"
7954 exit 1
8055 fi
56+ selected_branch=$( git -C " $WORKDIR /$repo_name " rev-parse --abbrev-ref HEAD)
57+ echo " ✅ Successfully cloned with default branch: $selected_branch "
8158fi
8259
8360# Verify repository
0 commit comments