gpt4 book ai didi

git - 在构建过程中获取git分支名称

转载 作者:太空狗 更新时间:2023-10-29 13:53:54 28 4
gpt4 key购买 nike

我想获取当前的 git 分支名称,以使用包含分支名称的文件名构建二进制文件。在带有 ant 的 Netbeans(7.1) 中这可能吗?

最佳答案

如果您不想处理 env 变量(如上述解决方案中所建议的那样)并且如果 git 命令可从您的命令行获得,则另一种解决方案是使用 ANT exec:

<exec executable="git" outputproperty="git.branch"
failifexecutionfails="false">
<arg line="rev-parse --abbrev-ref HEAD"/>
</exec>
<echo message="Current branch: ${git.branch}"/>

(解决方案基本上结合了 http://llbit.se/?p=1876How to get the current branch name in Git? )

关于git - 在构建过程中获取git分支名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9429677/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com