本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.MergeCommit方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.MergeCommit方法的具體用法?Golang MungeObject.MergeCommit怎麽用?Golang MungeObject.MergeCommit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.MungeObject
的用法示例。
在下文中一共展示了MungeObject.MergeCommit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Munge
// Munge is the workhorse the will actually make updates to the PR
func (c *ClearPickAfterMerge) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if !obj.HasLabel(cpCandidateLabel) {
return
}
if merged, err := obj.IsMerged(); !merged || err != nil {
return
}
releaseMilestone := obj.ReleaseMilestone()
if releaseMilestone == "" || len(releaseMilestone) != 4 {
glog.Errorf("Found invalid milestone: %q", releaseMilestone)
return
}
rel := releaseMilestone[1:]
branch := "release-" + rel
sha := obj.MergeCommit()
if sha == nil {
glog.Errorf("Unable to get SHA of merged %d", sha)
return
}
logMsg := fmt.Sprintf("Merge pull request #%d from ", *obj.Issue.Number)
bLogMsg := []byte(logMsg)
cherrypickMsg := fmt.Sprintf("(cherry picked from commit %s)", *sha)
args := []string{"log", "--pretty=tformat:%H%n%s%n%b", "--grep", cherrypickMsg, "origin/" + branch}
out, err := c.features.Repos.GitCommand(args)
if err != nil {
glog.Errorf("Error grepping for cherrypick -x message out=%q: %v", string(out), err)
return
}
if bytes.Contains(out, bLogMsg) {
glog.Infof("Found cherry-pick using -x information")
handleFound(obj, out, branch)
return
}
args = []string{"log", "--pretty=tformat:%H%n%s%n%b", "--grep", logMsg, "origin/" + branch}
out, err = c.features.Repos.GitCommand(args)
if err != nil {
glog.Errorf("Error grepping for log message out=%q: %v", string(out), err)
return
}
if bytes.Contains(out, bLogMsg) {
glog.Infof("Found cherry-pick using log matching")
handleFound(obj, out, branch)
return
}
return
}
示例2: foundByPickDashX
// Can we find a commit in the changelog that looks like it was done using git cherry-pick -m1 -x ?
func (c *ClearPickAfterMerge) foundByPickDashX(obj *github.MungeObject, branch string) bool {
sha := obj.MergeCommit()
if sha == nil {
glog.Errorf("Unable to get SHA of merged PR %d", *obj.Issue.Number)
return false
}
cherrypickMsg := fmt.Sprintf("(cherry picked from commit %s)", *sha)
found, logs := c.foundLog(branch, cherrypickMsg)
if !found {
return false
}
// double check for the 'non -x' message
logMsg := fmt.Sprintf("Merge pull request #%d from ", *obj.Issue.Number)
if !strings.Contains(logs, logMsg) {
return false
}
glog.Infof("Found cherry-pick for %d using -x information in branch %q", *obj.Issue.Number, branch)
return true
}