diff --git a/util.sh b/util.sh index 368b75b3543675c816af985db9df24ac771d5c26..a8f0c764f805ce76f88157b792355ec498d35c39 100644 --- a/util.sh +++ b/util.sh @@ -94,10 +94,19 @@ function clone_repo() { repo_name=${3:-$(echo "$1" | jq -r ".name")} clone_to=${2}/${repo_name} repo_url=$(echo "$1" | jq -r ".url") + repo_target=$(echo "$1" | jq -r ".revision") + rm -rf ${clone_to} + if [[ ${repo_target} != null ]]; then + git clone --recurse-submodules -q --depth 1 --branch ${DEF_VERSION} --no-tags ${repo_url} ${clone_to} 1>/dev/null 2>&1 + cd ${clone_to} + git fetch -f --depth=1 ${repo_url} ${repo_target} 1>/dev/null 2>&1 + git checkout ${repo_target} 1>/dev/null 2>&1 + cd - 1>/dev/null 2>&1 + return 0 + fi repo_target=$(echo "$1" | jq -r ".version") && [[ ${repo_target} != null ]] || repo_target=$(echo "$1" | jq -r ".branch") && [[ ${repo_target} != null ]] || repo_target=${DEF_VERSION} - rm -rf ${clone_to} git clone --recurse-submodules -q --depth 1 --branch ${repo_target} --no-tags ${repo_url} ${clone_to} 1>/dev/null 2>&1 } @@ -124,7 +133,8 @@ function update_repo() { repo_name=${3:-$(echo "$1" | jq -r ".name")} repo_path=${2}/${repo_name} repo_url=$(echo "$1" | jq -r ".url") - repo_target=$(echo "$1" | jq -r ".version") && [[ ${repo_target} != null ]] || + repo_target=$(echo "$1" | jq -r ".revision") && [[ ${repo_target} != null ]] || + repo_target=$(echo "$1" | jq -r ".version") && [[ ${repo_target} != null ]] || repo_target=$(echo "$1" | jq -r ".branch") && [[ ${repo_target} != null ]] || repo_target=${DEF_VERSION}