structurize script

+ seperate actions into functions for maintainability
+ use command line parameters for the svn list
master
nico wellpott 4 years ago
parent c3ee3b4654
commit 006678e272
Signed by: nwellpott
GPG Key ID: 1F6495B44DABCE6E

@ -1,9 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
REPOS=(skript scare scare2) REPOS=( "$@" )
BASE_PATH="/home/user/nwellpott/svnMigration" BASE_PATH="/home/user/nwellpott/svnMigration"
for REPO in "${REPOS[@]}"; do function migrate() {
# change dir # change dir
/usr/bin/printf "changing directory to %s\n" "$REPO" /usr/bin/printf "changing directory to %s\n" "$REPO"
cd "$BASE_PATH/$REPO" || exit 1 cd "$BASE_PATH/$REPO" || exit 1
@ -11,7 +11,26 @@ for REPO in "${REPOS[@]}"; do
# rebase # rebase
/usr/bin/printf "attempt to fetch %s commits\n" "$REPO" /usr/bin/printf "attempt to fetch %s commits\n" "$REPO"
/usr/bin/svn2git --rebase /usr/bin/svn2git --rebase
}
function clean() {
# clean up git tree thoroughly
/usr/bin/git gc --aggressive
}
function push() {
# push changes # push changes
# /usr/bin/git push --all /usr/bin/git push --all
# push tags
/usr/bin/git push --tags
}
# main
for REPO in "${REPOS[@]}"; do
migrate
clean
push
done done

Loading…
Cancel
Save