本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.IsForBranch方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.IsForBranch方法的具體用法?Golang MungeObject.IsForBranch怎麽用?Golang MungeObject.IsForBranch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.MungeObject
的用法示例。
在下文中一共展示了MungeObject.IsForBranch方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: prMustFollowRelNoteProcess
func (r *ReleaseNoteLabel) prMustFollowRelNoteProcess(obj *github.MungeObject) bool {
if obj.IsForBranch("master") {
return true
}
parents := getCherrypickParentPRs(obj, r.config)
// if it has no parents it needs to follow the release note process
if len(parents) == 0 {
return true
}
for _, parent := range parents {
// If the parent didn't set a release note, the CP must
if !parent.HasLabel(releaseNote) &&
!parent.HasLabel(releaseNoteActionRequired) {
if !obj.HasLabel(releaseNoteLabelNeeded) {
obj.WriteComment(parentReleaseNoteBody)
}
return true
}
}
// All of the parents set the releaseNote or releaseNoteActionRequired label,
// so this cherrypick PR needs to do nothing.
return false
}
示例2: Munge
// Munge is the workhorse the will actually make updates to the PR
func (c *CherrypickAutoApprove) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if obj.IsForBranch("master") {
return
}
if obj.HasLabel(cpApprovedLabel) && obj.ReleaseMilestone() != "" {
return
}
parents := getCherrypickParentPRs(obj, c.config)
if len(parents) == 0 {
return
}
major := 0
minor := 0
branch := obj.Branch()
if l, err := fmt.Sscanf(branch, "release-%d.%d", &major, &minor); err != nil || l != 2 {
return
}
branchImpliedMilestone := fmt.Sprintf("v%d.%d", major, minor)
milestone := obj.ReleaseMilestone()
if milestone != "" && milestone != branchImpliedMilestone {
glog.Errorf("Found PR %d on branch %q but have milestone %q", *obj.Issue.Number, branch, milestone)
return
}
for _, parent := range parents {
if !parent.HasLabel(cpApprovedLabel) {
return
}
// If the parent was for milestone v1.2 but this PR has
// comments saying it was 'on branch release-1.1' we should
// not auto approve
parentMilestone := parent.ReleaseMilestone()
if parentMilestone != branchImpliedMilestone {
glog.Errorf("%d: parentReleaseMilestone=%q but branch is %q", *obj.Issue.Number, parentMilestone, obj.Branch())
return
}
}
if milestone == "" {
obj.SetMilestone(branchImpliedMilestone)
}
if !obj.HasLabel(cpApprovedLabel) {
obj.AddLabel(cpApprovedLabel)
}
}
示例3: Munge
// Munge is the workhorse the will actually make updates to the PR
func (LabelUnapprovedPicks) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if obj.IsForBranch("master") {
return
}
if obj.HasLabel(cpApprovedLabel) {
return
}
obj.AddLabel(doNotMergeLabel)
msg := fmt.Sprintf("This PR is not for the master branch but does not have the `%s` label. Adding the `%s` label.", cpApprovedLabel, doNotMergeLabel)
obj.WriteComment(msg)
}
示例4: Munge
// Munge is the workhorse the will actually make updates to the PR
func (LabelUnapprovedPicks) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if obj.IsForBranch("master") {
return
}
if obj.HasLabel(cpApprovedLabel) {
return
}
if obj.HasLabel(doNotMergeLabel) {
return
}
obj.AddLabel(doNotMergeLabel)
obj.WriteComment(labelUnapprovedBody)
}
示例5: Munge
// Munge is the workhorse the will actually make updates to the PR
func (PingCIMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
// This munger only runs on certain branches, since travis/CI only listens
// on certain branches
validBranch := false
for _, b := range validBranches {
if obj.IsForBranch(b) {
validBranch = true
break
}
}
if !validBranch {
return
}
if !obj.HasLabel(lgtmLabel) {
return
}
mergeable, err := obj.IsMergeable()
if err != nil {
glog.V(2).Infof("ping CI skipping %d - problem determining mergeability", *obj.Issue.Number)
return
}
if !mergeable {
glog.V(2).Infof("ping CI skipping %d - not mergeable", *obj.Issue.Number)
return
}
if state := obj.GetStatusState([]string{travisContext}); state == "incomplete" {
msg := "Travis continuous integration appears to have missed, closing and re-opening to trigger it"
obj.WriteComment(msg)
obj.ClosePR()
time.Sleep(5 * time.Second)
obj.OpenPR(10)
}
}