diff options
Diffstat (limited to 'build/creating_data/download-git-repos.sh')
-rwxr-xr-x | build/creating_data/download-git-repos.sh | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/build/creating_data/download-git-repos.sh b/build/creating_data/download-git-repos.sh index 9d651d93..bb4a79f1 100755 --- a/build/creating_data/download-git-repos.sh +++ b/build/creating_data/download-git-repos.sh @@ -1,3 +1,4 @@ +#! /usr/bin/env bash # COPYRIGHT NOTICE STARTS HERE # # Copyright 2018 © Samsung Electronics Co., Ltd. @@ -16,21 +17,40 @@ # # COPYRIGHT NOTICE ENDS HERE -lists_dir="$1" +# fail fast +set -e -if [[ -z "$lists_dir" ]]; then - echo "Missing argument for lists_dir" +usage () { + echo "Usage:" + echo -e "./$(basename $0) <repository list> [destination directory]\n" + echo "Examples:" + echo " ./$(basename $0) onap_3.0.0 ./git-repo" +} + +LIST="${1}" + +if [[ -z "${LIST}" ]]; then + echo "Missing argument for repository list" exit 1 fi -outdir="$2" -if [[ -z "$outdir" ]]; then - outdir="./git-repo" +OUTDIR="${2}" +if [[ -z "${OUTDIR}" ]]; then + OUTDIR="./git-repo" fi -mkdir -p "$outdir" -cd "$outdir" -# NOTE: will be better to use sh extension? -sh $lists_dir/git_manual_list -sh $lists_dir/git_repos_list +mkdir -p "${OUTDIR}" +cd "${OUTDIR}" + + +while IFS=" " read -r REPO BRANCH remainder +do + if [[ -z "${BRANCH}" ]]; then + git clone https://${REPO} --bare ${REPO} + else + git clone -b ${BRANCH} --single-branch https://${REPO} --bare ${REPO} + fi +done < <(awk '$1 ~ /^[^;#]/' ${LIST}) + +exit 0 |