git钩检查标签名称 [英] Git hook to check tag name
问题描述
是否有任何git钩子检查新git标签的名称或字符串,甚至可能在提交"新标签之前(例如,类似pre-commit,但用于标签的东西)?我的问题的目的是我想禁止使用"abc"或"v1.2.3"格式的git标签名称.Git标签名称应始终严格遵循"1.2.3"语法.
Is there any git hook that checks the name or string of a new git tag, potentially even prior to "committing" the new tag (e.g. something like pre-commit, but for tags)? Purpose of my question is that I want to prohibit git tag names in the format of "abc" or "v1.2.3". Git tag names should always strictly follow to the "1.2.3" syntax.
推荐答案
如果您坚持在客户端使用钩子,则应为预推钩子.在服务器端,它应该是预先接收或更新的挂钩.类似于 https://stackoverflow.com/a/5810488/7976758 或
If you insist on a hook at the client side it should be pre-push hook. At the server side it should be pre-receive or update hook. Something like https://stackoverflow.com/a/5810488/7976758 or https://stackoverflow.com/a/8444966/7976758.
肯定没有用于标签的客户端挂钩.要在标签创建时检查没有钩子的标签名称,请为 git标签
写一个外壳包装或git别名-一个脚本,它将检查名称,然后调用 git标签"$ @"
.
There are certainly no client-side hooks for tags. To check tag names without hooks at the tag creation time write a shell wrapper or a git alias for git tag
— a script that will check the name and then call git tag "$@"
.
这篇关于git钩检查标签名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!