This page is no longer maintained — Please continue to the home page at www.scala-lang.org

github cloners: please update your tags

3 replies
extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.

So today's important lesson about git is that tags move around like a
virus and as long as anyone has a particular tag it is liable to keep
coming back from the dead. Apparently a mass vaccination effort is
required to eliminate them. On top of that, it is rocket science to
mass delete remote tags. So if you did something incredibly unwise
like renaming a bunch of tags, you will never be allowed to forget
about it.

Here's a script I wrote to delete all the tags off a remote.

**** IF YOU HAVE A SCALA CLONE ON GITHUB I NEED YOU TO RUN THIS ****

You can get back the correct tags after clearing all yours out with
something like

git fetch scala --tags

Where scala is whatever name you have for the remote at
https://github.com/scala/scala .

#!/usr/bin/env bash
#
# Deletes all tags off a git remote
# e.g. git-rm-remote-tags origin

[[ $# -eq 1 ]] || { echo "Usage: $0 "; exit 0; }

tagrefs () {
git ls-remote $remote | awk '{ print $2 }' | grep ^refs/tags/ | grep -v \{\}$
}
runner () {
echo Running: "$@"
"$@"
}

runner git push $remote $(
for ref in $(tagrefs); do
echo :$ref
done
)

dcsobral
Joined: 2009-04-23,
User offline. Last seen 38 weeks 5 days ago.
Re: github cloners: please update your tags

That was supposed to be

runner git push $0 $(

Or else there was something missing. I'm not sure what steps I should
have done and in which order, nor how do I verify if I'm now ok or
not.

On Thu, Dec 8, 2011 at 16:42, Paul Phillips wrote:
> So today's important lesson about git is that tags move around like a
> virus and as long as anyone has a particular tag it is liable to keep
> coming back from the dead.  Apparently a mass vaccination effort is
> required to eliminate them.  On top of that, it is rocket science to
> mass delete remote tags. So if you did something incredibly unwise
> like renaming a bunch of tags, you will never be allowed to forget
> about it.
>
> Here's a script I wrote to delete all the tags off a remote.
>
> **** IF YOU HAVE A SCALA CLONE ON GITHUB I NEED YOU TO RUN THIS ****
>
> You can get back the correct tags after clearing all yours out with
> something like
>
>  git fetch scala --tags
>
> Where scala is whatever name you have for the remote at
> https://github.com/scala/scala .
>
>
> #!/usr/bin/env bash
> #
> # Deletes all tags off a git remote
> # e.g. git-rm-remote-tags origin
>
> [[ $# -eq 1 ]] || { echo "Usage: $0 "; exit 0; }
>
> tagrefs () {
>  git ls-remote $remote | awk '{ print $2 }' | grep ^refs/tags/ | grep -v \{\}$
> }
> runner () {
>  echo Running: "$@"
>  "$@"
> }
>
> runner git push $remote $(
>  for ref in $(tagrefs); do
>    echo :$ref
>  done
> )

extempore
Joined: 2008-12-17,
User offline. Last seen 35 weeks 3 days ago.
Re: github cloners: please update your tags

Oh, these non-typesafe languages.

Here's another attempt. Deletes all local tags too. If you've really
deleted all the tags, this url:

https://github.com//scala/tags

Will say there are no tags.

#!/usr/bin/env bash
#
# Deletes all local tags and all tags off a remote
# e.g. git-rm-remote-tags origin

[[ $# -eq 1 ]] || { echo "Usage: $0 "; exit 0; }

remote="$1"

tagrefs () {
git 2>/dev/null ls-remote --tags $remote | awk '{ print $2 }' | grep -v \{\}$
}
runner () {
echo % "$@"
"$@"
}

runner git tag -d $(git tag -l)
runner git push $remote $(
for ref in $(tagrefs); do
echo :$ref
done
)

vlad.ureche
Joined: 2011-03-17,
User offline. Last seen 1 year 26 weeks ago.
Re: github cloners: please update your tags

On Thu, Dec 8, 2011 at 7:58 PM, Paul Phillips <paulp [at] improving [dot] org> wrote:
Oh, these non-typesafe languages.

Here's another attempt.  Deletes all local tags too.  If you've really
deleted all the tags, this url:

 https://github.com/<githubuser>/scala/tags

Will say there are no tags.


#!/usr/bin/env bash
#
# Deletes all local tags and all tags off a remote
# e.g. git-rm-remote-tags origin

[[ $# -eq 1 ]] || { echo "Usage: $0 <remote>"; exit 0; }

remote="$1"

tagrefs () {
 git 2>/dev/null ls-remote --tags $remote | awk '{ print $2 }' | grep -v \{\}$
}
runner () {
 echo % "$@"
 "$@"
}

runner git tag -d $(git tag -l)
runner git push $remote $(
 for ref in $(tagrefs); do
   echo :$ref
 done
)


The following script seemed to do the right job for me: 
#!/usr/bin/env bash
[[ $# -eq 1 ]] || { echo "Usage: $0 <scala/scala remote name>"; exit 0; }
for a in $(git tag -l)do         echo Deleting tag $a...        git tag -d $a        refs=$refs" :refs/tags/$a"done
git push origin $refsgit fetch $1 --tags git push origin --tags
and you use it like:
vlad@lampmac16:~/workspace/dev/scala$ git remote -vorigin   git [at] github [dot] com:VladUreche/scala.git (fetch) origin   git [at] github [dot] com:VladUreche/scala.git (push)scalascalaremote   https://github.com/scala/scala.git (fetch) scalascalaremote   https://github.com/scala/scala.git (push)
vlad@lampmac16:~/workspace/dev/scala$ ./git-rm-tags scalascalaremote

HTH
Vlad 

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland