使用Phing从存储库中获取最新的Git标记

moz*_*ami 7 git phing build

我是初学者并且需要构建一个脚本来自动化一些构建任务.

有没有办法只检索最近添加的标签到git仓库?我可以提取所有标签的列表,但似乎无法将其过滤到最新的标签.

这是获取我的git标签的相关代码:

    <gittag 
        repository="${repo.dir.resolved}" 
        list="true" 
        outputProperty="versionTag" 
        pattern="v*" />
Run Code Online (Sandbox Code Playgroud)

上面的输出结果是一个标签列表(前缀为"v"):

[gittag] git-tag output: v1.0.0
v1.0.1
v1.0.2
Run Code Online (Sandbox Code Playgroud)

关于如何将其归结为v1.0.2的任何想法?

moz*_*ami 7

管理完成如下操作:

    <exec 
        outputProperty="latestVersion" 
        command="git describe --tags `git rev-list --tags --max-count=1`" 
        dir="${repo.dir.resolved}"/>
Run Code Online (Sandbox Code Playgroud)

它确实有效,但如果可以改进,我愿意接受建议!

  • 我唯一的建议是扩展GitTag任务并提交包含的更改. (3认同)