git钩检查标签名称 [英] Git hook to check tag name

查看:54
本文介绍了git钩检查标签名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆