本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.ReleaseMilestone方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.ReleaseMilestone方法的具體用法?Golang MungeObject.ReleaseMilestone怎麽用?Golang MungeObject.ReleaseMilestone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.MungeObject
的用法示例。
在下文中一共展示了MungeObject.ReleaseMilestone方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: isStaleComment
func (PickMustHaveMilestone) isStaleComment(obj *github.MungeObject, comment *githubapi.IssueComment) bool {
if *comment.Body != pickMustHaveMilestoneBody {
return false
}
stale := obj.ReleaseMilestone() != ""
if stale {
glog.V(6).Infof("Found stale PickMustHaveMilestone comment")
}
return stale
}
示例3: 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)
}
}
示例4: Munge
// Munge is the workhorse the will actually make updates to the PR
func (PickMustHaveMilestone) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if !obj.HasLabel(cpCandidateLabel) {
return
}
releaseMilestone := obj.ReleaseMilestone()
hasLabel := obj.HasLabel(cpCandidateLabel)
if hasLabel && releaseMilestone == "" {
obj.WriteComment(pickMustHaveMilestoneBody)
obj.RemoveLabel(cpCandidateLabel)
}
}
示例5: objToStatusPullRequest
func objToStatusPullRequest(obj *github.MungeObject) *statusPullRequest {
if obj == nil {
return &statusPullRequest{}
}
res := statusPullRequest{
Number: *obj.Issue.Number,
URL: *obj.Issue.HTMLURL,
Title: *obj.Issue.Title,
Login: *obj.Issue.User.Login,
AvatarURL: *obj.Issue.User.AvatarURL,
}
pr, err := obj.GetPR()
if err != nil {
return &res
}
if pr.Additions != nil {
res.Additions = *pr.Additions
}
if pr.Deletions != nil {
res.Deletions = *pr.Deletions
}
prio, ok := obj.Annotations["priority"]
if !ok {
var prio string
p := priority(obj)
if p == retestNotRequiredMergePriority {
prio = retestNotRequiredLabel
} else {
prio = fmt.Sprintf("P%d", p) // store it a P1, P2, P3. Not just 1,2,3
}
obj.Annotations["priority"] = prio
}
if prio != "" {
res.ExtraInfo = append(res.ExtraInfo, prio)
}
milestone, ok := obj.Annotations["milestone"]
if !ok {
milestone = obj.ReleaseMilestone()
obj.Annotations["milestone"] = milestone
}
if milestone != "" {
res.ExtraInfo = append(res.ExtraInfo, milestone)
}
return &res
}
示例6: Munge
// Munge is the workhorse the will actually make updates to the PR
func (PickMustHaveMilestone) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if !obj.HasLabel(cpCandidateLabel) {
return
}
releaseMilestone := obj.ReleaseMilestone()
hasLabel := obj.HasLabel(cpCandidateLabel)
if hasLabel && releaseMilestone == "" {
msg := fmt.Sprintf("Removing label `%s` because no release milestone was set. This is an invalid state and thus this PR is not being considered for cherry-pick to any release branch. Please add an appropriate release milestone and then re-add the label.", cpCandidateLabel)
obj.WriteComment(msg)
obj.RemoveLabel(cpCandidateLabel)
}
}
示例7: 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
if c.foundByPickDashX(obj, branch) {
handleFound(obj, branch)
return
}
if c.foundByAllCommits(obj, branch) {
handleFound(obj, branch)
return
}
if c.foundByPickWithoutDashX(obj, branch) {
handleFound(obj, branch)
return
}
if c.foundByScript(obj, branch) {
handleFound(obj, branch)
return
}
return
}