From b2fac4bcb881f1ed96e634a265ff0ee3528925f7 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Wed, 12 Jun 2013 09:25:31 +0100 Subject: Delete any branches/tags which are newer than our reset commit. This prevents newer Mandriva tags and branches leaking into Mageia GIT repos --- scripts/mageia-reset-and-import.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/scripts/mageia-reset-and-import.sh b/scripts/mageia-reset-and-import.sh index b24abe5..da290ec 100755 --- a/scripts/mageia-reset-and-import.sh +++ b/scripts/mageia-reset-and-import.sh @@ -99,6 +99,30 @@ else git update-ref -m "Rewind SVN Git to pre-Magiea import" refs/remotes/trunk $resetsha1 git checkout master git reset --hard trunk + + # Remove any heads that are newer than this (except trunk) + resetreldate=$(git show -s --pretty='format:%ar' $resetsha1) + resettimestamp=$(git show -s --pretty='format:%at' $resetsha1) + echo "Removing any branches/tags newer than '$resetsha1' ($resetreldate)..." + git for-each-ref --format='%(refname)' refs/remotes/tags/* refs/remotes/branches/* | \ + while read ref; do + # As svn tags show as new commits, we mustn't parse $ref directly, but + # traverse back up the tag tree to find the first commit that *do not* + # result in any changes (i.e. not an svn cp) and use that as our reference + # comparison point. + refsha1=$(git rev-parse "$ref":) + parentref=$ref + while [ $(git rev-parse --quiet --verify "$parentref"^: ) = "$refsha1" ]; do + parentref="$parentref"^ + done + + reftimestamp=$(git show -s --pretty='format:%at' $parentref) + if [ $reftimestamp -gt $resettimestamp ]; then + echo " Removing '$ref'" + git update-ref -d $ref + fi + done + echo "... done" fi -- cgit v1.2.1