Skip to content
This repository has been archived by the owner on Dec 7, 2020. It is now read-only.

Rename all the old Git tags #629

Closed
abstractj opened this issue Jun 2, 2020 · 16 comments
Closed

Rename all the old Git tags #629

abstractj opened this issue Jun 2, 2020 · 16 comments
Assignees
Milestone

Comments

@abstractj
Copy link

Summary

Rename all the old Git tags from this repository to avoid any confusion in the further releases.

Why?

We have several Git tags created during the Gatekeeper releases. Now with Louketo, we're going to start on
Git tag 1.0.0.

The best way of doing this while still preserving the tags, is to rename all the tags to something like:
10.0.0-gatekeeper

How

  • Run all the tags locally
  • Push them

Acceptance criteria

  • All the tags renamed with the suffix -gatekeeper
@abstractj abstractj added this to the 1.0.0-alpha.1 milestone Jun 2, 2020
@abstractj
Copy link
Author

abstractj commented Jun 2, 2020

@stianst @ASzc could you please review this idea and let me know if makes sense to you guys? This is something we have to do prior the first release.

@abstractj abstractj self-assigned this Jun 2, 2020
@stianst
Copy link
Contributor

stianst commented Jun 3, 2020

I would probably go with a prefix rather than suffix, and something that sorts at the end of the list in GitHub UI to get them out of the way. Will Louketo use vX.Y.Z or X.Y.Z format for tags? If the former then I'd probably rename existing tags to something like "xGatekeeper-vX.Y.Z"

@ASzc
Copy link
Contributor

ASzc commented Jun 3, 2020

I agree with Stian's point about sorting.

Here's a script to do the renaming:

#!/bin/bash -ex

git fetch --tags origin
while read -r tag
do
    git push origin "refs/tags/$tag:refs/tags/xGatekeeper-$tag"
    git push -d origin "refs/tags/$tag"
    git tag -d "$tag"
done < <(git tag -l | grep -v '^xGatekeeper')

Anyone with an existing fork on GitHub will need to run the same script to have a clean fork. People who just have a local clone only can most easily just re-clone.

@abstractj
Copy link
Author

I would probably go with a prefix rather than suffix, and something that sorts at the end of the list in GitHub UI to get them out of the way. Will Louketo use vX.Y.Z or X.Y.Z format for tags? If the former then I'd probably rename existing tags to something like "xGatekeeper-vX.Y.Z"

Thanks will do that. Answering your question, I'd like to stick with X.Y.Z as vX.Y.Z is not considered a semantic version.

@ASzc thank you! I will give your script a try at my fork

@abstractj

This comment has been minimized.

@ASzc
Copy link
Contributor

ASzc commented Jun 3, 2020

Seems they use a reverse sort, so a lot of the usual tricks to get something to the end of a list don't work, as you've discovered.

What about prefixing the new version tags too?

Pattern for old tags: gatekeeper-$oldtag

Pattern for new tags: louketo-proxy-1.0.0

This happens to sort the way we want, at least in my trials with sort -Vr on the command line, although I haven't tested it on GitHub itself.

@abstractj
Copy link
Author

abstractj commented Jun 3, 2020

+1 we just need to remember to change the YAML files from #615 to remove the prefix. So we don't end up with something like louketo-proxy-louketo-proxy-1.0.0, but should be a simple change. I believe it's a great idea @ASzc.

@stianst wdyt?

@stianst
Copy link
Contributor

stianst commented Jun 4, 2020

I think the ideal is to have the new tags just x.y.z and I'm not to keen on prefixing those with louketo-proxy.

What about "0.9.0-gatekeeper-x.y.z" or something like that?

@ASzc
Copy link
Contributor

ASzc commented Jun 4, 2020

That would work from a sorting perspective.

@abstractj

This comment has been minimized.

@ASzc
Copy link
Contributor

ASzc commented Jun 4, 2020

If the script is to avoid touching already converted tags, then the grep pattern should be -Gatekeeper$

@abstractj
Copy link
Author

@ASzc using grep -v '-Gatekeeper$' returns an invalid pattern here. Maybe we should just change to grep -v '*-Gatekeeper$'. Wdyt?

@ASzc
Copy link
Contributor

ASzc commented Jun 4, 2020

Oh, oops, that's because grep needs -e before a pattern that starts with a -, to avoid interpreting the pattern as arguments. Prepending .* is also a valid workaround.

@abstractj
Copy link
Author

Thanks @ASzc. Script updated:

#!/bin/bash -ex

git fetch --tags origin
while read -r tag
do
    git push origin "refs/tags/$tag:refs/tags/0.$tag-Gatekeeper"
    git push -d origin "refs/tags/$tag"
    git tag -d "$tag"
done < <(git tag -l | grep -v -e '-Gatekeeper$')

Outcome

@stianst if you agree, I believe now we're good to go.

@stianst
Copy link
Contributor

stianst commented Jun 5, 2020

LGTM

@abstractj
Copy link
Author

Thank you. The changes were applied, so I'm closing it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants