本文整理汇总了Golang中k8s/io/contrib/mungegithub/github.Config.WriteComment方法的典型用法代码示例。如果您正苦于以下问题:Golang Config.WriteComment方法的具体用法?Golang Config.WriteComment怎么用?Golang Config.WriteComment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/contrib/mungegithub/github.Config
的用法示例。
在下文中一共展示了Config.WriteComment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: MungePullRequest
// MungePullRequest is the workhorse the will actually make updates to the PR
func (s *SizeMunger) MungePullRequest(config *github_util.Config, pr *github.PullRequest, issue *github.Issue, commits []github.RepositoryCommit, events []github.IssueEvent) {
s.getGeneratedFiles(config)
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
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_util.GetLabelsWithPrefix(issue.Labels, labelSizePrefix)
needsUpdate := true
for _, l := range existing {
if l == newLabel {
needsUpdate = false
continue
}
config.RemoveLabel(*pr.Number, l)
}
if needsUpdate {
config.AddLabels(*pr.Number, []string{newLabel})
body := fmt.Sprintf("Labelling this PR as %s", newLabel)
config.WriteComment(*pr.Number, body)
}
}
示例2: MungePullRequest
// MungePullRequest is the workhorse the will actually make updates to the PR
func (OkToTestMunger) MungePullRequest(config *github_util.Config, pr *github.PullRequest, issue *github.Issue, commits []github.RepositoryCommit, events []github.IssueEvent) {
if !github_util.HasLabel(issue.Labels, "lgtm") {
return
}
status, err := config.GetStatus(pr, []string{"Jenkins GCE e2e"})
if err != nil {
glog.Errorf("unexpected error getting status: %v", err)
return
}
if status == "incomplete" {
glog.V(2).Infof("status is incomplete, adding ok to test")
msg := `@k8s-bot ok to test
pr builder appears to be missing, activating due to 'lgtm' label.`
config.WriteComment(*pr.Number, msg)
}
}
示例3: MungePullRequest
// MungePullRequest is the workhorse the will actually make updates to the PR
func (LGTMAfterCommitMunger) MungePullRequest(config *github_util.Config, pr *github.PullRequest, issue *github.Issue, commits []github.RepositoryCommit, events []github.IssueEvent) {
if !github_util.HasLabel(issue.Labels, "lgtm") {
return
}
lastModified := github_util.LastModifiedTime(commits)
lgtmTime := github_util.LabelTime("lgtm", events)
if lastModified == nil || lgtmTime == nil {
glog.Errorf("PR %d unable to determine lastModified or lgtmTime", *pr.Number)
return
}
if lastModified.After(*lgtmTime) {
lgtmRemovedBody := "PR changed after LGTM, removing LGTM."
if err := config.WriteComment(*pr.Number, lgtmRemovedBody); err != nil {
return
}
config.RemoveLabel(*pr.Number, "lgtm")
}
}
示例4: MungePullRequest
// MungePullRequest is the workhorse the will actually make updates to the PR
func (PingCIMunger) MungePullRequest(config *github_util.Config, pr *github.PullRequest, issue *github.Issue, commits []github.RepositoryCommit, events []github.IssueEvent) {
if !github_util.HasLabel(issue.Labels, "lgtm") {
return
}
if mergeable, err := config.IsPRMergeable(pr); err != nil {
glog.V(2).Infof("Skipping %d - problem determining mergeability", *pr.Number)
} else if !mergeable {
glog.V(2).Infof("Skipping %d - not mergeable", *pr.Number)
}
status, err := config.GetStatus(pr, []string{"Shippable", "continuous-integration/travis-ci/pr"})
if err != nil {
glog.Errorf("unexpected error getting status: %v", err)
return
}
if status == "incomplete" {
glog.V(2).Infof("status is incomplete, closing and re-opening")
msg := "Continuous integration appears to have missed, closing and re-opening to trigger it"
config.WriteComment(*pr.Number, msg)
config.ClosePR(pr)
time.Sleep(5 * time.Second)
config.OpenPR(pr, 10)
}
}
示例5: MungePullRequest
// MungePullRequest is the workhorse the will actually make updates to the PR
func (sq *SubmitQueue) MungePullRequest(config *github_util.Config, pr *github_api.PullRequest, issue *github_api.Issue, commits []github_api.RepositoryCommit, events []github_api.IssueEvent) {
e2e := sq.e2e
userSet := sq.userWhitelist
if !github_util.HasLabels(issue.Labels, []string{"cla: yes"}) {
sq.SetPRStatus(pr, noCLA)
return
}
if mergeable, err := config.IsPRMergeable(pr); err != nil {
glog.V(2).Infof("Skipping %d - unable to determine mergeability", *pr.Number)
sq.SetPRStatus(pr, undeterminedMergability)
return
} else if !mergeable {
glog.V(4).Infof("Skipping %d - not mergable", *pr.Number)
sq.SetPRStatus(pr, unmergeable)
return
}
// Validate the status information for this PR
contexts := sq.RequiredStatusContexts
if len(sq.E2EStatusContext) > 0 && (len(sq.DontRequireE2ELabel) == 0 || !github_util.HasLabel(issue.Labels, sq.DontRequireE2ELabel)) {
contexts = append(contexts, sq.E2EStatusContext)
}
if ok := config.IsStatusSuccess(pr, contexts); !ok {
glog.Errorf("PR# %d Github CI status is not success", *pr.Number)
sq.SetPRStatus(pr, ciFailure)
return
}
if !github_util.HasLabel(issue.Labels, sq.WhitelistOverride) && !userSet.Has(*pr.User.Login) {
glog.V(4).Infof("Dropping %d since %s isn't in whitelist and %s isn't present", *pr.Number, *pr.User.Login, sq.WhitelistOverride)
if !github_util.HasLabel(issue.Labels, needsOKToMergeLabel) {
config.AddLabels(*pr.Number, []string{needsOKToMergeLabel})
body := "The author of this PR is not in the whitelist for merge, can one of the admins add the 'ok-to-merge' label?"
config.WriteComment(*pr.Number, body)
}
sq.SetPRStatus(pr, needsok)
return
}
// Tidy up the issue list.
if github_util.HasLabel(issue.Labels, needsOKToMergeLabel) {
config.RemoveLabel(*pr.Number, needsOKToMergeLabel)
}
if !github_util.HasLabels(issue.Labels, []string{"lgtm"}) {
sq.SetPRStatus(pr, noLGTM)
return
}
lastModifiedTime := github_util.LastModifiedTime(commits)
lgtmTime := github_util.LabelTime("lgtm", events)
if lastModifiedTime == nil || lgtmTime == nil {
glog.Errorf("PR %d was unable to determine when LGTM was added or when last modified", *pr.Number)
sq.SetPRStatus(pr, unknown)
return
}
if lastModifiedTime.After(*lgtmTime) {
glog.V(4).Infof("PR %d changed after LGTM. Will not merge", *pr.Number)
sq.SetPRStatus(pr, lgtmEarly)
return
}
if !e2e.Stable() {
sq.SetPRStatus(pr, e2eFailure)
return
}
// if there is a 'e2e-not-required' label, just merge it.
if len(sq.DontRequireE2ELabel) > 0 && github_util.HasLabel(issue.Labels, sq.DontRequireE2ELabel) {
config.MergePR(pr, "submit-queue")
sq.SetPRStatus(pr, merged)
return
}
sq.SetPRStatus(pr, githube2e)
sq.Lock()
sq.githubE2ERequest <- true
sq.needsGithubE2E[*pr.Number] = pr
sq.Unlock()
return
}