summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <colin@mageia.org>2013-06-12 09:54:52 +0100
committerColin Guthrie <colin@mageia.org>2013-06-12 09:54:52 +0100
commit09816159211b1f6d5526b32441e43b08f2b0afee (patch)
treea78e11da12926230dad9b4753f0bad4a8115de5b
parentb07eafd3d2c7c50d3079a440ded6cce1128a05e7 (diff)
downloadsvn-git-migration-09816159211b1f6d5526b32441e43b08f2b0afee.tar
svn-git-migration-09816159211b1f6d5526b32441e43b08f2b0afee.tar.gz
svn-git-migration-09816159211b1f6d5526b32441e43b08f2b0afee.tar.bz2
svn-git-migration-09816159211b1f6d5526b32441e43b08f2b0afee.tar.xz
svn-git-migration-09816159211b1f6d5526b32441e43b08f2b0afee.zip
Attempt to resolve tags into proper annotated tags.
The git-svn import stage doesn't automatically handle tags as well as it could. In order to make tags show up properly on master, we inspect each tag and try and find the first commit where it actually changes. We can then tag it via an annotated tag. Much nicer.
-rwxr-xr-xscripts/mageia-reset-and-import.sh37
1 files changed, 34 insertions, 3 deletions
diff --git a/scripts/mageia-reset-and-import.sh b/scripts/mageia-reset-and-import.sh
index 8a301c3..e7787cc 100755
--- a/scripts/mageia-reset-and-import.sh
+++ b/scripts/mageia-reset-and-import.sh
@@ -321,10 +321,41 @@ git push origin master 'refs/remotes/*:refs/heads/*'
pushd ../$SOFTWARE.git
git branch -D trunk
git branch -D origin/master
+
+# Tagging logic inspired by https://github.com/nothingmuch/git-svn-abandon/blob/master/git-svn-abandon-fix-refs
git for-each-ref --format='%(refname)' refs/heads/tags | cut -d / -f 4 | \
- while read ref; do
- git tag "$ref" "refs/heads/tags/$ref"
- git branch -D "tags/$ref"
+ while read tag; do
+ ref="refs/heads/tags/$tag"
+ refsha1=$(git rev-parse "$ref":)
+
+ # Find the oldest ancestor for which the tree is the same
+ parentref="$ref"
+ while [ $(git rev-parse --quiet --verify "$parentref"^:) = "$refsha1" ]; do
+ parentref="$parentref"^
+ done
+ parent=$(git rev-parse "$parentref")
+
+ # If this ancestor is in master then we can just tag it
+ # otherwise the tag has diverged from master and it's actually more like a
+ # branch than a tag
+ merge=$(git merge-base master $parent)
+ if [ "$merge" = "$parent" ]; then
+ targetref=$parent
+ else
+ targetref="$ref"
+ fi
+
+ # create an annotated tag based on the last commit in the tag, and delete the "branchy" ref for the tag
+ git show -s --pretty='format:%s%n%n%b' "$ref" | \
+ env GIT_COMMITTER_NAME="$(git show -s --pretty='format:%an' "$ref")" \
+ GIT_COMMITTER_EMAIL="$(git show -s --pretty='format:%ae' "$ref")" \
+ GIT_COMMITTER_DATE="$(git show -s --pretty='format:%ad' "$ref")" \
+ GIT_AUTHOR_NAME="$(git show -s --pretty='format:%an' "$ref")" \
+ GIT_AUTHOR_EMAIL="$(git show -s --pretty='format:%ae' "$ref")" \
+ GIT_AUTHOR_DATE="$(git show -s --pretty='format:%ad' "$ref")" \
+ git tag -a -F - "$tag" "$targetref"
+
+ git update-ref -d "$ref"
done
git gc --aggressive