本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.GetPR方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.GetPR方法的具體用法?Golang MungeObject.GetPR怎麽用?Golang MungeObject.GetPR使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.MungeObject
的用法示例。
在下文中一共展示了MungeObject.GetPR方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Munge
// Munge is the workhorse the will actually make updates to the PR
func (a *AssignFixesMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
// we need the PR for the "User" (creator of the PR not the assignee)
pr, err := obj.GetPR()
if err != nil {
glog.Infof("Couldn't get PR %v", obj.Issue.Number)
return
}
prOwner := github.DescribeUser(pr.User)
issuesFixed := obj.GetPRFixesList()
if issuesFixed == nil {
return
}
for _, fixesNum := range issuesFixed {
// "issue" is the issue referenced by the "fixes #<num>"
issueObj, err := a.config.GetObject(fixesNum)
if err != nil {
glog.Infof("Couldn't get issue %v", fixesNum)
continue
}
issue := issueObj.Issue
if !a.AssignfixesReassign && issue.Assignee != nil {
glog.V(6).Infof("skipping %v: reassign: %v assignee: %v", *issue.Number, a.AssignfixesReassign, github.DescribeUser(issue.Assignee))
continue
}
glog.Infof("Assigning %v to %v (previously assigned to %v)", *issue.Number, prOwner, github.DescribeUser(issue.Assignee))
// although it says "AssignPR" it's more generic than that and is really just an issue.
issueObj.AssignPR(prOwner)
}
}
示例2: findLastHumanPullRequestUpdate
func findLastHumanPullRequestUpdate(obj *github.MungeObject) (*time.Time, error) {
pr, err := obj.GetPR()
if err != nil {
return nil, err
}
comments, err := obj.ListReviewComments()
if err != nil {
return nil, err
}
lastHuman := pr.CreatedAt
for i := range comments {
comment := comments[i]
if comment.User == nil || comment.User.Login == nil || comment.CreatedAt == nil || comment.Body == nil {
continue
}
if *comment.User.Login == botName || *comment.User.Login == jenkinsBotName {
continue
}
if lastHuman.Before(*comment.UpdatedAt) {
lastHuman = comment.UpdatedAt
}
}
return lastHuman, nil
}
示例3: Munge
// Munge is the workhorse the will actually make updates to the PR
func (c *CherrypickQueue) Munge(obj *github.MungeObject) {
if !obj.HasLabel(cpCandidateLabel) {
return
}
if !obj.IsPR() {
return
}
// This will cache the PR and events so when we try to view the queue we don't
// hit github while trying to load the page
obj.GetPR()
num := *obj.Issue.Number
c.Lock()
merged, _ := obj.IsMerged()
if merged {
if obj.HasLabel(cpApprovedLabel) {
c.mergedAndApproved[num] = obj
} else {
c.merged[num] = obj
}
} else {
c.unmerged[num] = obj
}
c.Unlock()
return
}
示例4: 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
}
示例5: Munge
// Munge is the workhorse the will actually make updates to the PR
func (s *SizeMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
issue := obj.Issue
pr, err := obj.GetPR()
if err != nil {
return
}
s.getGeneratedFiles(obj)
genFiles := *s.genFiles
genPrefixes := *s.genPrefixes
if pr.Additions == nil {
glog.Warningf("PR %d has nil Additions", *pr.Number)
return
}
adds := *pr.Additions
if pr.Deletions == nil {
glog.Warningf("PR %d has nil Deletions", *pr.Number)
return
}
dels := *pr.Deletions
commits, err := obj.GetCommits()
if err != nil {
return
}
for _, c := range commits {
for _, f := range c.Files {
for _, p := range genPrefixes {
if strings.HasPrefix(*f.Filename, p) {
adds = adds - *f.Additions
dels = dels - *f.Deletions
continue
}
}
if genFiles.Has(*f.Filename) {
adds = adds - *f.Additions
dels = dels - *f.Deletions
continue
}
}
}
newSize := calculateSize(adds, dels)
newLabel := labelSizePrefix + newSize
existing := github.GetLabelsWithPrefix(issue.Labels, labelSizePrefix)
needsUpdate := true
for _, l := range existing {
if l == newLabel {
needsUpdate = false
continue
}
obj.RemoveLabel(l)
}
if needsUpdate {
obj.AddLabels([]string{newLabel})
body := fmt.Sprintf("Labelling this PR as %s", newLabel)
obj.WriteComment(body)
}
}