gpt4 book ai didi

git - grgit:在build.gradle脚本中添加标签并将文件推送到远程分支

转载 作者:行者123 更新时间:2023-12-03 05:07:20 28 4
gpt4 key购买 nike

我正在尝试使用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

为了使两者都能正常工作,我还需要做其他事情吗?

谢谢。

最佳答案

我找到了解决上述问题的方法。这是我所做的:

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()

}
}

关于git - grgit:在build.gradle脚本中添加标签并将文件推送到远程分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55418712/

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