[GRASS-SVN] r74084 - grass-addons/tools/svn2git

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 12 10:19:12 PST 2019


Author: martinl
Date: 2019-02-12 10:19:12 -0800 (Tue, 12 Feb 2019)
New Revision: 74084

Modified:
   grass-addons/tools/svn2git/1-migrate-core.sh
Log:
svn2git: rewrite partialy a tool for migrating grass/grass-legacy repos

Modified: grass-addons/tools/svn2git/1-migrate-core.sh
===================================================================
--- grass-addons/tools/svn2git/1-migrate-core.sh	2019-02-12 17:39:25 UTC (rev 74083)
+++ grass-addons/tools/svn2git/1-migrate-core.sh	2019-02-12 18:19:12 UTC (rev 74084)
@@ -1,68 +1,59 @@
-#!/bin/sh
+#!/bin/sh -x
 
-SCRIPT=`realpath $0` # realpath is a separate package and doesn't need to be installed
-SCRIPTPATH=`dirname $SCRIPT`
+migrate_git() {
+    DIR=$1
+    
+    rm -rf $DIR
+    cp -r grass-fetch $DIR
+    cd $DIR
 
-# TO BE SET
-DIR=grass
-### DIR=grass-legacy
+    # Create local branches
+    if [ $DIR = "grass" ] ; then
+        branch_filter="releasebranch_7"
+    else
+        branch_filter="releasebranch_[0-6]"
+    fi
+    for branch in `git branch -r | grep $branch_filter | sed 's#  origin/##g'`; do
+        git branch $branch origin/$branch
+    done
+    if [ $DIR = "grass" ] ; then
+        git branch master origin/trunk
+        git checkout master
+    fi
 
-rm -rf $DIR
-cp -r grass-fetch $DIR
-cd $DIR
-
-# Create local branches
-if [ $DIR = "grass" ] ; then
-    branch_filter="releasebranch_7"
-else
-    branch_filter="releasebranch_[0-6]"
-fi
-for branch in `git branch -r | grep $branch_filter | sed 's#  origin/##g'`; do
-    git branch $branch origin/$branch
-done
-if [ $DIR = "grass" ] ; then
-    git branch master origin/trunk
-    git checkout master
-fi
-
-# Rename tags
-if [ $DIR = "grass" ] ; then
-    tag_filter="grass_7"
-else
-    tag_filter="grass_[0-6]"
-fi
-for i in `git branch -r | grep tags | grep $tag_filter`; do
-    b=`echo $i | sed 's#origin/##'`
-    if [ `echo $i | grep -c release` -gt 0 ] ; then
-        j=`echo $i | sed 's#origin/tags/release_[0-9]\+_##g'`
+    # Rename tags
+    if [ $DIR = "grass" ] ; then
+        tag_filter="grass_7"
     else
-        j=`echo $i | sed 's#origin/tags/##g'`
+        tag_filter="grass_[0-6]"
     fi
-    git branch $b $i
-    d=`git log -1 --format=%cd --date=iso $b`
-    h=`git log -1 --format=%h --date=iso $b`
-    GIT_COMMITTER_DATE="$d" git tag -a $j -m "Tagging release $j" $h
-done
+    for i in `git branch -r | grep tags | grep $tag_filter`; do
+        b=`echo $i | sed 's#origin/##'`
+        if [ `echo $i | grep -c release` -gt 0 ] ; then
+            j=`echo $i | sed 's#origin/tags/release_[0-9]\+_##g'`
+        else
+            j=`echo $i | sed 's#origin/tags/##g'`
+        fi
+        git branch $b $i
+        d=`git log -1 --format=%cd --date=iso $b`
+        h=`git log -1 --format=%h --date=iso $b`
+        GIT_COMMITTER_DATE="$d" git tag -a $j -m "Tagging release $j" $h
+    done
 
-if [ $DIR = "grass" ] ; then
-    git checkout master
-fi
-for i in `git branch | grep tags`; do
-    git branch -D $i
-done
+    if [ $DIR = "grass" ] ; then
+        git checkout master
+    fi
+    for i in `git branch | grep tags`; do
+        git branch -D $i
+    done
 
-# Remove remote branches
-for i in `git branch -r | grep origin`; do
-    git branch -dr $i
-done
+    # Remove remote branches
+    for i in `git branch -r | grep origin`; do
+        git branch -dr $i
+    done
 
-# Fix commit messages (#x -> https://trac.osgeo.org/...)
-git reset --hard HEAD
-for b in `git branch | cut -c 3-`; do
-    git checkout $b
-    git filter-branch --msg-filter "python  $SCRIPTPATH/rewrite.py" -- --all
-    # check out /tmp/log_touched.txt and /tmp/log_untoched.txt for changes overview ...
-    mv /tmp/log_touched.txt log_${b}_touched.txt
-    mv /tmp/log_untouched.txt log_${b}_untouched.txt
-done
+    cd ..
+}
 
+migrate_git "grass"
+migrate_git "grass-legacy"



More information about the grass-commit mailing list