#!/bin/bash

set -e -u
set FILTER_BRANCH_SQUELCH_WARNING=0

rm -rf data
mkdir -p data

cd data

git clone /data/srv/git/canhub.bck canhub
cd canhub

# git filter-branch --env-filter'
#    if test "$GIT_AUTHOR_EMAIL" = "maximilian.seesslen@ifm.com"
#    then
#	GIT_AUTHOR_EMAIL=mes@seesslen.net
#    fi
#' -- --all

# Erzeugt viele refs
git-filter-repo --force \
    --email-callback 'return email.replace(b"maximilian.seesslen@ifm.com", b"mes@seesslen.net")' \
    --replace-refs update-no-add

git-filter-repo --force \
    --email-callback 'return email.replace(b"mes@seesslen.net", b"dev@seesslen.net")' \
    --replace-refs update-no-add

git remote add origin /data/srv/git/canhub
git push --all -f
git push --tags -f

#git remote set-url origin /srv/git/canhub.git

echo "[$0] fin."

#---fin------------------------------------------------------------------------
