本文整理匯總了Golang中k8s/io/contrib/mungegithub/github.MungeObject.WriteComment方法的典型用法代碼示例。如果您正苦於以下問題:Golang MungeObject.WriteComment方法的具體用法?Golang MungeObject.WriteComment怎麽用?Golang MungeObject.WriteComment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/contrib/mungegithub/github.MungeObject
的用法示例。
在下文中一共展示了MungeObject.WriteComment方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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)
}
}
示例2: Munge
// Munge is the workhorse the will actually make updates to the PR
func (r *RebuildMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
comments, err := obj.ListComments()
if err != nil {
glog.Errorf("unexpected error getting comments: %v", err)
}
for ix := range comments {
comment := comments[ix]
// Skip all robot comments
if r.robots.Has(*comment.User.Login) {
glog.V(4).Infof("Skipping comment by robot %s: %s", *comment.User.Login, *comment.Body)
continue
}
if isRebuildComment(comment) && rebuildCommentMissingIssueNumber(comment) {
if err := obj.DeleteComment(comment); err != nil {
glog.Errorf("Error deleting comment: %v", err)
continue
}
body := fmt.Sprintf(rebuildFormat, *comment.User.Login)
err := obj.WriteComment(body)
if err != nil {
glog.Errorf("unexpected error adding comment: %v", err)
continue
}
}
}
}
示例3: Munge
// Munge is the workhorse the will actually make updates to the PR
func (b *BlockPath) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if obj.HasLabel(doNotMergeLabel) {
return
}
files, err := obj.ListFiles()
if err != nil {
return
}
for _, f := range files {
if matchesAny(*f.Filename, b.blockRegexp) {
if matchesAny(*f.Filename, b.doNotBlockRegexp) {
continue
}
obj.WriteComment(blockPathBody)
obj.AddLabels([]string{doNotMergeLabel})
return
}
}
}
示例4: 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
}
示例5: Munge
// Munge is the workhorse the will actually make updates to the PR
func (b *BlockPath) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if obj.HasLabel(doNotMergeLabel) {
return
}
commits, err := obj.GetCommits()
if err != nil {
return
}
for _, c := range commits {
for _, f := range c.Files {
if matchesAny(*f.Filename, b.blockRegexp) {
if matchesAny(*f.Filename, b.doNotBlockRegexp) {
continue
}
body := fmt.Sprintf(`Adding label:%s because PR changes docs prohibited to auto merge
See http://kubernetes.io/editdocs/ for information about editing docs`, doNotMergeLabel)
obj.WriteComment(body)
obj.AddLabels([]string{doNotMergeLabel})
return
}
}
}
}
示例6: Munge
// Munge is the workhorse the will actually make updates to the PR
func (StaleGreenCI) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if !obj.HasLabel(lgtmLabel) {
return
}
if mergeable, err := obj.IsMergeable(); !mergeable || err != nil {
return
}
if !obj.IsStatusSuccess(requiredContexts) {
return
}
for _, context := range requiredContexts {
statusTime := obj.GetStatusTime(context)
if statusTime == nil {
glog.Errorf("%d: unable to determine time %q context was set", *obj.Issue.Number, context)
return
}
if time.Since(*statusTime) > staleGreenCIHours*time.Hour {
obj.WriteComment(greenMsgBody)
err := obj.WaitForPending(requiredContexts)
if err != nil {
glog.Errorf("Failed waiting for PR to start testing: %v", err)
}
return
}
}
}
示例7: Munge
// Munge is the workhorse the will actually make updates to the PR
func (NagFlakeIssues) Munge(obj *mgh.MungeObject) {
if obj.IsPR() || !obj.HasLabel("kind/flake") {
return
}
comments, err := obj.ListComments()
if err != nil {
glog.Error(err)
return
}
// Use the pinger to notify assignees:
// - Set time period based on configuration (at the top of this file)
// - Mention list of assignees as an argument
// - Start the ping timer after the last HumanActor comment
// How often should we ping
period := findTimePeriod(obj.Issue.Labels)
// Who are we pinging
who := mungerutil.GetIssueUsers(obj.Issue).Assignees.Mention().Join()
// When does the pinger start
startDate := c.LastComment(comments, c.HumanActor(), obj.Issue.CreatedAt)
// Get a notification if it's time to ping.
notif := pinger.SetTimePeriod(period).PingNotification(
comments,
who,
startDate,
)
if notif != nil {
obj.WriteComment(notif.String())
}
}
示例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("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")
}
}
示例9: Munge
// Munge is the workhorse the will actually make updates to the PR
func (PingCIMunger) Munge(obj *github.MungeObject) {
if !obj.IsPR() {
return
}
if !obj.HasLabel("lgtm") {
return
}
mergeable, err := obj.IsMergeable()
if err != nil {
glog.V(2).Infof("Skipping %d - problem determining mergeability", *obj.Issue.Number)
return
}
if !mergeable {
glog.V(2).Infof("Skipping %d - not mergeable", *obj.Issue.Number)
return
}
if state := obj.GetStatusState([]string{jenkinsCIContext, travisContext}); state != "incomplete" {
glog.V(2).Info("Have %s status - skipping ping CI", jenkinsCIContext)
return
}
state := obj.GetStatusState([]string{shippableContext, travisContext})
if state == "incomplete" {
msg := "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)
}
}
示例10: Munge
// Munge is the workhorse the will actually make updates to the PR
func (StalePendingCI) Munge(obj *github.MungeObject) {
requiredContexts := []string{jenkinsUnitContext, jenkinsE2EContext}
if !obj.IsPR() {
return
}
if !obj.HasLabel(lgtmLabel) {
return
}
if mergeable, err := obj.IsMergeable(); !mergeable || err != nil {
return
}
status := obj.GetStatusState(requiredContexts)
if status != "pending" {
return
}
for _, context := range requiredContexts {
statusTime := obj.GetStatusTime(context)
if statusTime == nil {
glog.Errorf("%d: unable to determine time %q context was set", *obj.Issue.Number, context)
return
}
if time.Since(*statusTime) > stalePendingCIHours*time.Hour {
obj.WriteComment(pendingMsgBody)
return
}
}
}
示例11: 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)
}
}
示例12: doGithubE2EAndMerge
func (sq *SubmitQueue) doGithubE2EAndMerge(obj *github.MungeObject) {
err := obj.Refresh()
if err != nil {
glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
sq.SetMergeStatus(obj, unknown)
return
}
if !sq.validForMerge(obj) {
return
}
if obj.HasLabel(e2eNotRequiredLabel) {
obj.MergePR("submit-queue")
sq.SetMergeStatus(obj, merged)
return
}
if err := obj.WriteComment(verifySafeToMergeBody); err != nil {
glog.Errorf("%d: unknown err: %v", *obj.Issue.Number, err)
sq.SetMergeStatus(obj, unknown)
return
}
// Wait for the build to start
sq.SetMergeStatus(obj, ghE2EWaitingStart)
err = obj.WaitForPending([]string{sq.E2EStatusContext, sq.UnitStatusContext})
if err != nil {
s := fmt.Sprintf("Failed waiting for PR to start testing: %v", err)
sq.SetMergeStatus(obj, s)
return
}
// Wait for the status to go back to something other than pending
sq.SetMergeStatus(obj, ghE2ERunning)
err = obj.WaitForNotPending([]string{sq.E2EStatusContext, sq.UnitStatusContext})
if err != nil {
s := fmt.Sprintf("Failed waiting for PR to finish testing: %v", err)
sq.SetMergeStatus(obj, s)
return
}
// Check if the thing we care about is success
if ok := obj.IsStatusSuccess([]string{sq.E2EStatusContext, sq.UnitStatusContext}); !ok {
sq.SetMergeStatus(obj, ghE2EFailed)
return
}
if !sq.e2eStable() {
sq.SetMergeStatus(obj, e2eFailure)
return
}
obj.MergePR("submit-queue")
sq.updateMergeRate()
sq.SetMergeStatus(obj, merged)
return
}
示例13: 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)
}
示例14: closePullRequest
func closePullRequest(obj *github.MungeObject, inactiveFor time.Duration) {
comment := findLatestWarningComment(obj)
if comment != nil {
obj.DeleteComment(comment)
}
obj.WriteComment(fmt.Sprintf(closingComment, durationToDays(inactiveFor)))
obj.ClosePR()
}
示例15: 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
}