How to automatically rename tags using git hooks?

I want all user-created tags to be validated (and renamed if necessary) to satisfy our rules.
For example, if a user created a tag "v1.2.3", it should be automatically renamed to "v1.02.03".

Unfortunately, there is a git hook that is invoked by the command git tag.

This is why I applied a hook pre-pushthat removes the old tag and creates a new (with a changed name) with the same commit.

The problem is that it git push --tagssends OLD TAGS to the remote repo instead of NEW TAGS (although the old tags no longer exist after the remote trailer deleted them).

How to rename tags automatically on a local repo before pushing them to a remote repo?


EDIT:
I solved my problem by duplicating the tag renaming logic post-receiveon the server side.
At the moment, the tag "v1.2.3" is renamed to "v1.02.03" from the client side using pre-pushhook, but the name of the old tag ("v1.2.3") is transferred to the remote repo and on the remote repo ", v1.2.3" is again renamed in "v1.02.03" with a post-receivehook. Now both the client and server renamed the tag.

Do I have to say that I am dissatisfied with my decision?
A clean client solution is still welcome.

+4
2

git, : --tags, refs , . manpage git -push:

   --tags
       All refs under refs/tags are pushed, in addition to refspecs explicitly listed on the command line.

refs , , / , .

IMO, , -, , , . .

- git, git push --tags. bash script git.

+2

pre-push hook .

0

Source: https://habr.com/ru/post/1662239/


All Articles