本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.RemoveLabel方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.RemoveLabel方法的具體用法?Golang MungeObject.RemoveLabel怎麽用?Golang MungeObject.RemoveLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.MungeObject
的用法示例。
在下文中一共展示了MungeObject.RemoveLabel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Munge
// Munge is the workhorse the will actually make updates to the PR
// The algorithm goes as:
// - Initially, we build an approverSet
// - Go through all comments after latest commit.
// - If anyone said "/approve", add them to approverSet.
// - Then, for each file, we see if any approver of this file is in approverSet and keep track of files without approval
// - An approver of a file is defined as:
// - Someone listed as an "approver" in an OWNERS file in the files directory OR
// - in one of the file's parent directorie
// - Iff all files have been approved, the bot will add the "approved" label.
// - Iff a cancel command is found, that reviewer will be removed from the approverSet
// and the munger will remove the approved label if it has been applied
func (h *ApprovalHandler) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
files, err := obj.ListFiles()
if err != nil {
glog.Errorf("failed to list files in this PR: %v", err)
return
}
comments, err := getCommentsAfterLastModified(obj)
if err != nil {
glog.Errorf("failed to get comments in this PR: %v", err)
return
}
ownersMap := h.getApprovedOwners(files, createApproverSet(comments))
if err := h.updateNotification(obj, ownersMap); err != nil {
return
}
for _, approverSet := range ownersMap {
if approverSet.Len() == 0 {
if obj.HasLabel(approvedLabel) {
obj.RemoveLabel(approvedLabel)
}
return
}
}
if !obj.HasLabel(approvedLabel) {
obj.AddLabel(approvedLabel)
}
}
示例2: removeLGTMIfCancelled
func (h *LGTMHandler) removeLGTMIfCancelled(obj *github.MungeObject, comments []*githubapi.IssueComment, reviewers mungerutil.UserSet) {
for i := len(comments) - 1; i >= 0; i-- {
comment := comments[i]
if !mungerutil.IsValidUser(comment.User) {
continue
}
if !mungerutil.IsMungeBot(comment.User) && !isReviewer(comment.User, reviewers) {
continue
}
fields := getFields(*comment.Body)
if isLGTMComment(fields) {
// "/lgtm" if commented more recently than "/lgtm cancel"
return
}
if !isCancelComment(fields) {
continue
}
glog.Infof("Removing lgtm label. Reviewer (%s) cancelled", *comment.User.Login)
obj.RemoveLabel(lgtmLabel)
return
}
}
示例3: Munge
// Munge is the workhorse the will actually make updates to the PR
func (p *PathLabelMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
files, err := obj.ListFiles()
if err != nil {
return
}
needsLabels := sets.NewString()
for _, f := range files {
for _, lm := range p.labelMap {
if lm.regexp.MatchString(*f.Filename) {
needsLabels.Insert(lm.label)
}
}
}
// This is all labels on the issue that the path munger controls
hasLabels := obj.LabelSet().Intersection(p.allLabels)
missingLabels := needsLabels.Difference(hasLabels)
if missingLabels.Len() != 0 {
obj.AddLabels(needsLabels.List())
}
extraLabels := hasLabels.Difference(needsLabels)
for _, label := range extraLabels.List() {
creator := obj.LabelCreator(label)
if creator == botName {
obj.RemoveLabel(label)
}
}
}
示例4: removeLGTMIfCancelled
func (h *LGTMHandler) removeLGTMIfCancelled(obj *github.MungeObject, comments []*githubapi.IssueComment, events []*githubapi.IssueEvent, reviewers mungerutil.UserSet) {
// Get time when the last (unlabeled, lgtm) event occurred.
addLGTMTime := e.LastEvent(events, e.And{e.AddLabel{}, e.LabelName(lgtmLabel), e.HumanActor()}, nil)
for i := len(comments) - 1; i >= 0; i-- {
comment := comments[i]
if !mungerutil.IsValidUser(comment.User) {
continue
}
if !mungerutil.IsMungeBot(comment.User) && !isReviewer(comment.User, reviewers) {
continue
}
fields := getFields(*comment.Body)
if isLGTMComment(fields) {
// "/lgtm" if commented more recently than "/lgtm cancel"
return
}
if !isCancelComment(fields) {
continue
}
// check if someone manually added the lgtm label after the `/lgtm cancel` comment
// and honor it.
if addLGTMTime != nil && addLGTMTime.After(*comment.CreatedAt) {
return
}
glog.Infof("Removing lgtm label. Reviewer (%s) cancelled", *comment.User.Login)
obj.RemoveLabel(lgtmLabel)
return
}
}
示例5: Munge
// Munge is the workhorse the will actually make updates to the PR
func (LGTMAfterCommitMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if !obj.HasLabel("lgtm") {
return
}
lastModified := obj.LastModifiedTime()
lgtmTime := obj.LabelTime("lgtm")
if lastModified == nil || lgtmTime == nil {
glog.Errorf("PR %d unable to determine lastModified or lgtmTime", *obj.Issue.Number)
return
}
if lastModified.After(*lgtmTime) {
glog.Infof("PR: %d lgtm:%s lastModified:%s", *obj.Issue.Number, lgtmTime.String(), lastModified.String())
lgtmRemovedBody := "PR changed after LGTM, removing LGTM."
if err := obj.WriteComment(lgtmRemovedBody); err != nil {
return
}
obj.RemoveLabel("lgtm")
}
}
示例6: getHumanCorrectedLabel
func getHumanCorrectedLabel(obj *github.MungeObject, s string) *string {
myEvents, err := obj.GetEvents()
if err != nil {
glog.Errorf("Could not get the events associated with Issue %d", obj.Issue.Number)
return nil
}
botEvents := event.FilterEvents(myEvents, event.And([]event.Matcher{event.BotActor(), event.AddLabel{}, event.LabelPrefix(s)}))
if botEvents.Empty() {
return nil
}
humanEventsAfter := event.FilterEvents(
myEvents,
event.And([]event.Matcher{
event.HumanActor(),
event.AddLabel{},
event.LabelPrefix(s),
event.CreatedAfter(*botEvents.GetLast().CreatedAt),
}),
)
if humanEventsAfter.Empty() {
return nil
}
lastHumanLabel := humanEventsAfter.GetLast()
glog.Infof("Recopying human-added label: %s for PR %d", *lastHumanLabel.Label.Name, *obj.Issue.Number)
obj.RemoveLabel(*lastHumanLabel.Label.Name)
obj.AddLabel(*lastHumanLabel.Label.Name)
return lastHumanLabel.Label.Name
}
示例7: Process
// Process does the necessary processing to compute whether to stay in
// this state, or proceed to the next.
func (p *PreReview) Process(obj *githubhelper.MungeObject) (State, error) {
success := true
if !p.checkCLA(obj) {
success = false
}
if !p.checkReleaseNotes(obj) {
success = false
}
if !p.checkAssignees(obj) {
success = false
}
if success {
if obj.HasLabel(labelPreReview) {
obj.RemoveLabel(labelPreReview)
}
return &NeedsReview{}, nil
}
if !obj.HasLabel(labelPreReview) {
obj.AddLabel(labelPreReview)
}
return &End{}, nil
}
示例8: Munge
// Munge is the workhorse the will actually make updates to the PR
func (LGTMAfterCommitMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if !obj.HasLabel(lgtmLabel) {
return
}
lastModified := obj.LastModifiedTime()
lgtmTime := obj.LabelTime(lgtmLabel)
if lastModified == nil || lgtmTime == nil {
glog.Errorf("PR %d unable to determine lastModified or lgtmTime", *obj.Issue.Number)
return
}
if lastModified.After(*lgtmTime) {
glog.Infof("PR: %d lgtm:%s lastModified:%s", *obj.Issue.Number, lgtmTime.String(), lastModified.String())
body := fmt.Sprintf(lgtmRemovedBody, mungerutil.GetIssueUsers(obj.Issue).AllUsers().Mention().Join())
if err := obj.WriteComment(body); err != nil {
return
}
obj.RemoveLabel(lgtmLabel)
}
}
示例9: 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
s.getGeneratedFiles(obj)
genFiles := *s.genFiles
genPrefixes := *s.genPrefixes
files, err := obj.ListFiles()
if err != nil {
return
}
adds := 0
dels := 0
for _, f := range files {
skip := false
for _, p := range genPrefixes {
if strings.HasPrefix(*f.Filename, p) {
skip = true
break
}
}
if skip {
continue
}
if genFiles.Has(*f.Filename) {
continue
}
if f.Additions != nil {
adds += *f.Additions
}
if f.Deletions != nil {
dels += *f.Deletions
}
}
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)
}
}
示例10: Munge
// Munge is unused by this munger.
func (cla *ClaMunger) Munge(obj *githubhelper.MungeObject) {
if !obj.IsPR() {
return
}
if obj.HasLabel(claHumanLabel) {
return
}
status := obj.GetStatusState([]string{cla.CLAStatusContext})
// Check for pending status and exit.
if status == contextPending {
// do nothing and wait for state to be updated.
return
}
if status == contextSuccess {
if obj.HasLabel(cncfClaYesLabel) {
// status is success and we've already applied 'cncf-cla: yes'.
return
}
if obj.HasLabel(cncfClaNoLabel) {
obj.RemoveLabel(cncfClaNoLabel)
}
obj.AddLabel(cncfClaYesLabel)
return
}
// If we are here, that means that the context is failure/error.
comments, err := obj.ListComments()
if err != nil {
glog.Error(err)
return
}
who := mungerutil.GetIssueUsers(obj.Issue).Author.Mention().Join()
// Get a notification if it's time to ping.
notif := cla.pinger.PingNotification(
comments,
who,
nil,
)
if notif != nil {
obj.WriteComment(notif.String())
}
if obj.HasLabel(cncfClaNoLabel) {
// status reported error/failure and we've already applied 'cncf-cla: no' label.
return
}
if obj.HasLabel(cncfClaYesLabel) {
obj.RemoveLabel(cncfClaYesLabel)
}
obj.AddLabel(cncfClaNoLabel)
}
示例11: handleFound
func handleFound(obj *github.MungeObject, gitMsg []byte, branch string) error {
msg := string(gitMsg)
o := strings.SplitN(msg, "\n", 2)
sha := o[0]
msg = fmt.Sprintf("Commit %s found in the %q branch appears to be this PR. Removing the %q label. If this s an error find help to get your PR picked.", sha, branch, cpCandidateLabel)
obj.WriteComment(msg)
obj.RemoveLabel(cpCandidateLabel)
return nil
}
示例12: 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)
}
}
示例13: Munge
// Munge is the workhorse the will actually make updates to the PR
func (NeedsRebaseMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
mergeable, err := obj.IsMergeable()
if err != nil {
glog.V(2).Infof("Skipping %d - problem determining mergeable", *obj.Issue.Number)
return
}
if mergeable && obj.HasLabel(needsRebase) {
obj.RemoveLabel(needsRebase)
}
if !mergeable && !obj.HasLabel(needsRebase) {
obj.AddLabels([]string{needsRebase})
}
}
示例14: Munge
// Munge is the workhorse the will actually make updates to the PR
func (DocsNeedNoRetest) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
files, err := obj.ListFiles()
if err != nil {
glog.Errorf("Failed to list files for PR %d: %s", obj.Issue.Number, err)
}
docsOnly := areFilesDocOnly(files)
if docsOnly && !obj.HasLabel(labelSkipRetest) {
obj.AddLabel(labelSkipRetest)
} else if !docsOnly && obj.HasLabel(labelSkipRetest) {
obj.RemoveLabel(labelSkipRetest)
}
}
示例15: 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)
}
}