#!/bin/sh set -uex SUBDIR="" while getopts ":d:" opt; do case $opt in d) SUBDIR="$OPTARG" ;; \?) echo "Invalid option: -$OPTARG" exit 1 ;; :) echo "Option -$OPTARG requires an argument." exit 1 ;; esac done # Shift past the last option parsed by getopts shift $((OPTIND-1)) if [ -d .git ] ; then git gc --aggressive --prune=now REPO="$(basename "$(git rev-parse --show-toplevel)")" cd .. else [ -n "$1" ] || exit 1 REPO="$1" (cd "$REPO" git gc --aggressive --prune=now ) fi GITDIR="$(readlink -f "${REPO}").git" git clone --bare "$REPO" "${GITDIR}" (cd "${GITDIR}" # shellcheck disable=SC3045 read -r -e -p "Describe the repository:" DESC echo "$DESC" >description touch git-daemon-export-ok git config --add gitweb.owner 'Matěj Cepl ' git remote rm origin || /bin/true ) rsync -avz "${GITDIR}" redcrew:/srv/git/ rm -rf "${GITDIR}" cd "$REPO" git remote add myrepo "https://git.cepl.eu/cgit/${REPO}" git remote set-url --push myrepo "redcrew:/srv/git/${REPO}.git" # if git remote show gitlab >/dev/null 2>&1 ; then # git remote remove gitlab # fi git remote update git push --all -u myrepo