#!/bin/bash

REPONAME=$1
SRCURL=$2
DSTURL=$3

if [ -z "$DSTURL" ]; then
    echo "Usage: $0 <repository name> <github URL> <gitlab SSH URL>"
    exit 1
fi

REPODIR=/home/gitlabmirror/repos/${REPONAME}.git

rm -rf $REPODIR

/usr/bin/git clone --bare $SRCURL $REPODIR

/usr/bin/git -C $REPODIR remote add gitlab $DSTURL

/usr/bin/git -C $REPODIR push --mirror gitlab
