Skip to content

Commit

Permalink
Add script to rewrite old tags
Browse files Browse the repository at this point in the history
This is educational mostly, it just shows how the process in rewriting
tags for the issue #72 was done. Since it was an one-off process, this
was not automated completely, we updated old releases manually.
  • Loading branch information
punycode committed Apr 13, 2020
1 parent 65d202f commit f04efe5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions scripts/oneoff/rewrite_old_tags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh

set -o errexit
set -o pipefail

for old_tag in $(git tag -l | grep '^coffeenet-starter-'); do
new_tag=$(echo "${old_tag}" | sed -E -e 's/^coffeenet-starter-(.*)/v\1/')
echo "Fixing up tag: ${old_tag} -> ${new_tag}"
tag_type=$(git cat-file -t "${old_tag}")
if [ $tag_type = "tag" ]; then
echo "Annotated tag ${old_tag}, rewriting tag object"
new_hash=$(git cat-file -p "${old_tag}" | sed -e "s/^tag .*/tag ${new_tag}/" | git mktag)
git update-ref "refs/tags/${new_tag}" $new_hash
elif [ $tag_type = "commit" ]; then
git tag -f "${new_tag}" "${old_tag}"
else
echo "ref type for ${old_tag} unknown, dont know what to do"
fi
done

0 comments on commit f04efe5

Please sign in to comment.