blob: 7853a141ab5e46b5d4d9866708e897b49d62e6c7 [file] [log] [blame]
Tomáš Levoraade405a2019-01-29 14:25:04 +01001#! /usr/bin/env bash
Piotr Perzanowski2d8d1652018-12-18 13:53:35 +01002# COPYRIGHT NOTICE STARTS HERE
3#
4# Copyright 2018 © Samsung Electronics Co., Ltd.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# COPYRIGHT NOTICE ENDS HERE
Petr Ospalý03e61242019-01-03 16:54:50 +010019
Tomáš Levoraade405a2019-01-29 14:25:04 +010020# fail fast
21set -e
Petr Ospalý03e61242019-01-03 16:54:50 +010022
Tomáš Levoraade405a2019-01-29 14:25:04 +010023usage () {
24 echo "Usage:"
25 echo -e "./$(basename $0) <repository list> [destination directory]\n"
26 echo "Examples:"
Michal Ptacek90ec0cf2019-04-03 13:55:29 +000027 echo " ./$(basename $0) onap_3.0.x-git_repos.list ./git-repo"
Tomáš Levoraade405a2019-01-29 14:25:04 +010028}
29
30LIST="${1}"
31
32if [[ -z "${LIST}" ]]; then
33 echo "Missing argument for repository list"
Piotr Perzanowski2d8d1652018-12-18 13:53:35 +010034 exit 1
35fi
Petr Ospalý03e61242019-01-03 16:54:50 +010036
Tomáš Levoraade405a2019-01-29 14:25:04 +010037OUTDIR="${2}"
38if [[ -z "${OUTDIR}" ]]; then
39 OUTDIR="./git-repo"
Piotr Perzanowski2d8d1652018-12-18 13:53:35 +010040fi
Petr Ospalý03e61242019-01-03 16:54:50 +010041
Tomáš Levoraade405a2019-01-29 14:25:04 +010042mkdir -p "${OUTDIR}"
43cd "${OUTDIR}"
Petr Ospalý03e61242019-01-03 16:54:50 +010044
Tomáš Levoraade405a2019-01-29 14:25:04 +010045
46while IFS=" " read -r REPO BRANCH remainder
47do
48 if [[ -z "${BRANCH}" ]]; then
49 git clone https://${REPO} --bare ${REPO}
50 else
51 git clone -b ${BRANCH} --single-branch https://${REPO} --bare ${REPO}
52 fi
53done < <(awk '$1 ~ /^[^;#]/' ${LIST})
54
55
56exit 0