Skip to content

Instantly share code, notes, and snippets.

@milouse
Created December 21, 2016 17:48
Show Gist options
  • Save milouse/f305202c66b9df7e473037cd1f1cfa6b to your computer and use it in GitHub Desktop.
Save milouse/f305202c66b9df7e473037cd1f1cfa6b to your computer and use it in GitHub Desktop.
Shell script to create (and update) a git mirror of a fossil repository
#!/usr/bin/env bash
# This script should be called from a bare git repository
# $1 should contain the path to the fossil file to export
[ -z "$1" ] && exit 1
[ -f tmp_export_file ] && rm tmp_export_file
fossil export --git "$1" > tmp_export_file
sed -i "s/fossil_user <fossil_user>/Étienne Deparis <[email protected]>/g" tmp_export_file
cat tmp_export_file | git fast-import
if [ -n "$2" -a "$2" = 'github' ]; then
GITHUB_TARGET=$(git remote -v | grep 'github.com:milouse' | head -n1 | cut -f1)
git push $GITHUB_TARGET trunk
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment