Skip to content

Instantly share code, notes, and snippets.

@schnell18
Created December 25, 2013 14:19
Show Gist options
  • Save schnell18/8123560 to your computer and use it in GitHub Desktop.
Save schnell18/8123560 to your computer and use it in GitHub Desktop.
This script converts lightweight tags migrated from Subversion to annotated tags. It also moves the tag to it parent commit which is identical to itself. This makes the git describe works as expected.
#!/bin/bash
echo "Convert lightweight tag to annotated tag..."
for tg in $(git tag |grep REL)
do
newtag=${tg#REL_}
newtag=${newtag//_/.}
cmt=$(git log -1 --pretty=%s $tg)
tagger=$(git log -1 --pretty=%an $tg)
tagmail=$(git log -1 --pretty=%ae $tg)
tagdate=$(git log -1 --pretty=%ad $tg)
export GIT_COMMITTER_EMAIL=$tagmail
export GIT_COMMITTER_DATE=$tagdate
export GIT_COMMITTER_NAME=$tagger
dff=$(git diff $tg^ $tg)
if [[ -z $dff ]]
then
git tag -a -m "$cmt" $newtag $tg^
else
git tag -a -m "$cmt" $newtag $tg
fi
git tag -d $tg
done
# vim: set ai nu nobk expandtab sw=4 ts=4 syntax=sh:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment