Last active
April 3, 2026 12:12
-
-
Save mgoellnitz/06c58374e3457ab220c979b1a4dc4bf3 to your computer and use it in GitHub Desktop.
Mirror GIT repositories into existing Fossil SCM repositories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # | |
| # Providing and maintaining a mirror of a GIT repository on a in a local | |
| # Fossil SCM based repository system by means of this rather simple shell script | |
| # wrapper around the Fossil base functionality | |
| # | |
| # | |
| # Copyright 2016-2026 Martin Goellnitz | |
| # | |
| # 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, either version 3 of the License, or | |
| # (at your option) any later version. | |
| # | |
| # 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 Lesser 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/>. | |
| # | |
| BASE=$(pwd) | |
| DIR=$BASE | |
| REPO=$(git remote get-url origin 2> /dev/null|head -1) | |
| if [ "$1" = "-s" ] ; then | |
| SIMULATE=true | |
| shift | |
| fi | |
| if [ -z "$REPO" ] ; then | |
| if [ -z "$1" ] ; then | |
| echo "Must be in cloned git repository directory" | |
| echo "or better give the repository database filename as the first parameter to $(basename "$0")" | |
| exit 1 | |
| fi | |
| if [ ! -z "$(echo $1|grep :)" ] ; then | |
| # checkout repo and go there | |
| rm -rf git-mirror | |
| git clone "$1" git-mirror 2> /dev/null | |
| DIR=git-mirror | |
| REPO=$(cd $DIR;git remote get-url origin 2> /dev/null|head -1) | |
| shift | |
| else | |
| echo "No git repository source to clone given as the first parameter to $(basename "$0")" | |
| exit 1 | |
| fi | |
| fi | |
| BRANCH=$(cd $DIR;git branch --show-current) | |
| REPO="$BASE/$(basename $REPO .git).fossil" | |
| if [ ! -z "$1" ] ; then | |
| REPO="$(dirname $1)/$(basename $1 .fossil).fossil" | |
| fi | |
| if [ -z "$SIMULATE" ] ; then | |
| PARAM=-i | |
| if [ ! -f "$REPO" ] ; then | |
| fsl init "$REPO" > /dev/null | |
| PARAM=-f | |
| fi | |
| (cd $DIR ; git fast-export --all) | fossil import --git --rename-trunk trunk "$PARAM" "$REPO" > /dev/null | |
| fi | |
| rm -rf git-mirror |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment