summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2013-07-23 09:17:51 +0100
committerColin Guthrie <colin@mageia.org>2013-07-23 09:20:14 +0100
commitbb65e4fb63653178b9d4645d06f5d0289e38225b (patch)
tree5f985cef11ca1f7c30ab6afa04db8fc802d706a4
parent63523fcc433c0c38bd0ca5787c1ac0b9cf8cd5b6 (diff)
downloadsvn-git-migration-bb65e4fb63653178b9d4645d06f5d0289e38225b.tar
svn-git-migration-bb65e4fb63653178b9d4645d06f5d0289e38225b.tar.gz
svn-git-migration-bb65e4fb63653178b9d4645d06f5d0289e38225b.tar.bz2
svn-git-migration-bb65e4fb63653178b9d4645d06f5d0289e38225b.tar.xz
svn-git-migration-bb65e4fb63653178b9d4645d06f5d0289e38225b.zip
As discussed on QA list implement a branch name policy.
We do not allow any branch names, but to allow for an easy import we have adopted this strategy: 1. Branches matching ([1-3]) are renamed to distro/mga\1 2. Branches matching (20[0-9\.]+) are renamed to distro/mdv\1 3. Branches matching (mes[0-9].*) are renamed to distro/\1 4. All other branches are renamed to topic/\1 (excl. master)
-rwxr-xr-xscripts/mageia-reset-and-import.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/mageia-reset-and-import.sh b/scripts/mageia-reset-and-import.sh
index 2c0dc80..4cd9e53 100755
--- a/scripts/mageia-reset-and-import.sh
+++ b/scripts/mageia-reset-and-import.sh
@@ -385,6 +385,44 @@ for tag in $tags; do
git update-ref -d "$ref"
done
+# Implement a branch name policy
+# 1. Branches matching ([1-3]) are renamed to distro/mga\1
+# 2. Branches matching (20[0-9\.]+) are renamed to distro/mdv\1
+# 3. Branches matching (mes[0-9].*) are renamed to distro/\1
+# 4. All other branches are renamed to topic/\1 (excl. master)
+
+branches=$(git for-each-ref --format='%(refname)' refs/heads | cut -d / -f 3-)
+for branch in $branches; do
+ ref="refs/heads/$branch"
+ refsha1=$(git rev-parse "$ref")
+ reftreesha1=$(git rev-parse "$ref":)
+
+ # Find the oldest ancestor for which the tree is the same
+ parentref="$ref"
+ while [ $(git rev-parse --quiet --verify "$parentref"^:) = "$reftreesha1" ]; do
+ parentref="$parentref"^
+ done
+ parent=$(git rev-parse "$parentref")
+
+ # If this ancestor is in master then we can just squash it
+ # otherwise the branch has diverged from master and it's actually a proper
+ # branch
+ merge=$(git merge-base master $parent)
+ if [ "$merge" = "$parent" ]; then
+ git update-ref "$ref" $parent $refsha1
+ fi
+
+ if (echo $branch | grep -qE '^[0-3]$'); then
+ git branch -m $branch distro/mga$branch
+ elif (echo $branch | grep -qE '^20[0-9\.]+$'); then
+ git branch -m $branch distro/mdv$branch
+ elif (echo $branch | grep -qE '^mes[0-9].*$'); then
+ git branch -m $branch distro/$branch
+ elif [ $branch != "master" ]; then
+ git branch -m $branch topic/$branch
+ fi
+done
+
git gc --aggressive
popd