我正在尝试使用grgit添加git标签,提交并将文件推送到远程分支。这是我想要做的:
//Task to push updated build.info to remote branch
task pushToOrigin {
doLast {
def grgit = Grgit.open(dir: ".")
grgit.add(patterns: ['web/build.info'])
grgit.tag.add(
name: "Tag3",
message: "Release of 3-${grgit.head()}",
force: true
)
grgit.commit(message: "Updating build.info")
//push to remote
grgit.push(remote:"${branch}", tags: true)
//grgit.push(remote:"${branch}")
//cleanup
grgit.close()
}
println "Completed task: pushToOrigin"
}
我注意到grgit.push(remote:"${branch}", tags: true)
添加了标签并将标签推送到远程,但没有推送我暂存的文件更改。
但是,grgit.push(remote:"${branch}")
会推送暂存的文件更改,但不会推送标签。
我正在使用Gradle 5.3,grgit版本2.3.0
为了使两者都能正常工作,我还需要做其他事情吗?
谢谢。
答案 0 :(得分:0)
我找到了解决上述问题的方法。这是我所做的:
task pushToOrigin {
doLast {
def grgit = Grgit.open(dir: ".")
grgit.add(patterns: ['web/build.info'])
grgit.commit(message: "Updating build.info")
//Push to remote
grgit.push(remote:"${branch}")
//Tag
tagName = "tag1"
grgit.tag.add(
name: tagName,
message: "Release of ${tagName}"
)
//Push
grgit.push(remote:"${branch}", refsOrSpecs: [tagName])
//cleanup
grgit.close()
}
}