support main branch for app to test as git repository

This commit is contained in:
Salamandar 2024-03-23 19:01:26 +01:00
parent b9640a3ffb
commit 211ec2aefd

View file

@ -322,7 +322,7 @@ function fetch_package_to_test() {
# If the url is on a specific branch, extract the branch # If the url is on a specific branch, extract the branch
if echo "$path_to_package_to_test" | grep -Eq "https?:\/\/.*\/tree\/" if echo "$path_to_package_to_test" | grep -Eq "https?:\/\/.*\/tree\/"
then then
gitbranch="-b ${path_to_package_to_test##*/tree/}" gitbranch="${path_to_package_to_test##*/tree/}"
path_to_package_to_test="${path_to_package_to_test%%/tree/*}" path_to_package_to_test="${path_to_package_to_test%%/tree/*}"
fi fi
@ -331,28 +331,25 @@ function fetch_package_to_test() {
package_path="$TEST_CONTEXT/app_folder" package_path="$TEST_CONTEXT/app_folder"
# If the package is in a git repository # If the package is in a git repository
if echo "$path_to_package_to_test" | grep -Eq "https?:\/\/" if echo "$path_to_package_to_test" | grep -Eq "https?:\/\/"; then
then
# Force the branch master if no branch is specified. # Force the branch master if no branch is specified.
if [ -z "$gitbranch" ] if [ -z "$gitbranch" ]; then
then branches=(master main stable)
if git ls-remote --quiet --exit-code $path_to_package_to_test master >/dev/null for branch in "${branches[@]}"; do
then if git ls-remote --quiet --exit-code "$path_to_package_to_test" "$branch" >/dev/null; then
gitbranch="-b master" gitbranch="$branch"
else break
if git ls-remote --quiet --exit-code $path_to_package_to_test stable >/dev/null fi
then done
gitbranch="-b stable" if [ -z "$gitbranch" ]; then
else
log_critical "Unable to find a default branch to test (master or stable)" log_critical "Unable to find a default branch to test (master or stable)"
fi fi
fi fi
fi
log_info " on branch ${gitbranch##-b }" log_info " on branch ${gitbranch}"
# Clone the repository # Clone the repository
git clone --quiet $path_to_package_to_test $gitbranch "$package_path" git clone --quiet $path_to_package_to_test -b "$gitbranch" "$package_path"
if [[ ! -e "$package_path" ]] if [[ ! -e "$package_path" ]]
then then