Created
May 24, 2020 20:57
-
-
Save mbarkhau/c49877ce4a506d6d8676107fd6305bca to your computer and use it in GitHub Desktop.
A helper script to migrate mercurial repositories to gitlab/github
This file contains 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/bash | |
set -e; | |
REPOUSER=mbarkhau | |
mkdir -p $HOME/workspace | |
cd $HOME/workspace | |
if ! [[ -d fast-export ]]; then | |
git clone https://github.com/frej/fast-export.git | |
fi | |
if ! [[ -d $1-hg ]]; then | |
hg clone ssh://[email protected]/$REPOUSER/$1 $1-hg | |
fi | |
mkdir -p $1 | |
cd $1 | |
if ! [[ -d .git ]]; then | |
git init | |
$HOME/workspace/fast-export/hg-fast-export.sh -r ../$1-hg/ | |
fi | |
git checkout HEAD | |
cat << EOF > .git/config | |
[core] | |
repositoryformatversion = 0 | |
filemode = true | |
bare = false | |
logallrefupdates = true | |
[remote "origin"] | |
url = [email protected]:$REPOUSER/$1.git | |
fetch = +refs/heads/*:refs/remotes/origin/* | |
[remote "gitlab"] | |
url = [email protected]:$REPOUSER/$1.git | |
fetch = +refs/heads/*:refs/remotes/origin/* | |
[remote "github"] | |
url = [email protected]:$REPOUSER/$1.git | |
fetch = +refs/heads/*:refs/remotes/origin/* | |
[branch "master"] | |
remote = origin | |
merge = refs/heads/master | |
EOF | |
git push |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment