Skip to content

Instantly share code, notes, and snippets.

@tshakah
Last active March 31, 2017 10:36
Show Gist options
  • Save tshakah/7629f6bedfd9feb0fab71415f938ae2e to your computer and use it in GitHub Desktop.
Save tshakah/7629f6bedfd9feb0fab71415f938ae2e to your computer and use it in GitHub Desktop.
#!/bin/bash
# Make sure to edit TEAM and EMAIL_DOMAIN
project=${PWD##*/}
current_dir="$project-git"
hg pull
hg update
hg log | grep user: | sort | uniq | sed 's/user: *//' > ../$project-authors-raw
hg log | grep tag: | sort | uniq | sed 's/tag: *//' > ../$project-tags-raw
hg log | grep branch: | sort | uniq | sed 's/branch: *//' > ../$project-branches-raw
while read value; do
result=${value// /-}
result=${result//\//-}
result=${result//\(/-}
result=${result//\)/}
result=${result//:/}
result=${result//#/}
result=${result//&/and}
result=${result//---/-}
result=${result//--/-}
result=${result//_-/-}
result=${result//-_/-}
echo $result >> ../$project-branches-closed
echo $value"="$result >> ../$project-branches
done <../$project-branches-raw
while read value; do
result=${value// /-}
result=${result//\//-}
result=${result//\(/-}
result=${result//\)/}
result=${result//:/}
result=${result//#/}
result=${result//&/and}
result=${result//---/-}
result=${result//--/-}
result=${result//_-/-}
result=${result//-_/-}
echo $value"="$result >> ../$project-tags
done <../$project-tags-raw
hg branches | cut -f1 -d" " >> ../$project-branches-open
while read value; do
result=$(echo $value | sed -e "s/<[a-zA-Z0-9]*@[a-zA-Z0-9.-]*>//g" | cut -f1 -d" " -f2 -d" " | cut -f1 -d"@")
result="$result $(echo $result | sed -e "s/ //g" -e "s/$/@EMAIL_DOMAIN>/g" -e "s/^/</g" | tr "[:upper:]" "[:lower:]")"
echo $value=$result >> ../$project-authors
done <../$project-authors-raw
cd ../
rm $project-branches-raw
rm $project-authors-raw
rm $project-tags-raw
mkdir $current_dir
cd $current_dir
git init
git remote add origin git@gitlab.com:TEAM/$project.git
#!/bin/bash
# Create the git remote project before running this script
project=${PWD##*/}
cd "../$project-git"
../../fast-export/hg-fast-export.sh -r ../$project -A ../$project-authors -B ../$project-branches -T ../$project-tags --force
git gc --aggressive
IFS=$'\r\n' GLOBIGNORE='*' command eval 'arr=($(cat ../$project-branches-open))'
while read value; do
if ! [[ " ${arr[@]} " =~ " ${value} " ]]; then
git tag archive/$value $value
git branch -D $value
fi
done <../$project-branches-closed
git push origin '*:*'
git push origin --all
rm $project-branches-open
rm $project-branches-closed
rm $project-branches
rm $project-authors
rm $project-tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment