git post hook内的分支名称 [英] Branch name within git post hook
问题描述
其意图是,只要有人推到这个裸回购,一个钩子会触发它调用另一个脚本并通过它
由于repo的名称(已经这样做了)以及刚刚推送的分支的分支名称。在 git post-receive hook如何获取它正在运行的repo的名称?中提到,一个post-receive钩子可以接收来自多个分支的提交:
#!/ bin / bash
while readre oldrev newrev refname
做
branch = $(git rev-parse --symbolic --abbrev-ref $ refname)
if [master==$ branch];然后
#调用您的脚本
fi
完成
您的脚本可能最终被称为多次次。
So I used this method to access the name of a repo within a git serverside hook. Is there a way to access the branch name as well?
The intention is that whenever someone pushes to this bare repo, a hook will trigger that calls another script and passes it the name of the repo (already does this) as well as the branch name of the branch that was just pushed.
As mentioned in "how can git post-receive hook get name of repo it is running on?", a post-receive hook can receive commits from multiple branches:
#!/bin/bash
while read oldrev newrev refname
do
branch=$(git rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
# Call your script
fi
done
Your script could end up being called multiple times.
这篇关于git post hook内的分支名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!