#!/bin/bash
SVER='1.0.3'

##############################################################################
#  gitpatterns - Update local github clones
#  Copyright (C) 2020-2021 SUSE LLC
#
# Description:  Updates the local pattern repositories from github clones
# Modified:     2022 Nov 01
#
##############################################################################
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; version 2 of the License.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, see <http://www.gnu.org/licenses/>.
#
#  Authors/Contributors:
#     Jason Record <jason.record@suse.com>
#
##############################################################################

LCONF='/etc/opt/patdevel/patdev.conf'
[[ -s $LCONF ]] && . $LCONF || { echo "ERROR: File not found, $LCONF"; echo; exit 1; }

echo "########################################################"
echo "# gitpatterns v${SVER}"
echo "########################################################"
echo "Base Dir: $PATDEV_REPOS_DIR"
echo "Repos:    $PATDEV_REPOS"
echo

cd $PATDEV_REPOS_DIR
for i in $PATDEV_REPOS
do
	if [[ -d $i ]]; then
		echo "Updating $i Repo..."
		cd $i
		git pull
		cd ..
	else
		echo "Cloning $i Repo..."
		git clone https://github.com/g23guy/${i}.git
	fi
	echo
done

