如何获取Git预推钩子refname [英] How to get Git pre-push hook refname
本文介绍了如何获取Git预推钩子refname的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用预推钩子来从带注释的标签自动生成更改日志.我想检查被推送的引用是否为tag
.
传递给pre-push钩子的参数不包含被推送的refname.如何获得?
I am using pre-push hook to generate change-log automatically from the annotated tags. I want to check if the ref being pushed is tag
or not.
The arguments passed to pre-push hook doesn't contain the refname being pushed. How to get it?
使用git push origin <tag>
推荐答案
使用bash shell,您可以使用以下代码来获得所需的内容:
With bash shell, you could use the following code to get what you need:
#!/bin/bash
remote=$1
url=$2
#above are the 2 parameters
#below are from the stdin
while read local_ref local_sha remote_ref remote_sha
do
#if pushing a tag, local_ref would be refs/tags/...
done
这篇关于如何获取Git预推钩子refname的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文