From 207b673fa738822c5c009202cf2f493950d90520 Mon Sep 17 00:00:00 2001 From: georgecao Date: Wed, 22 Sep 2021 20:22:54 +0800 Subject: [PATCH 1/2] Update member notice info while create a pull request. --- config.yaml | 5 ++++- pkg/cibot/config/config.go | 2 ++ pkg/cibot/pullrequest.go | 11 +++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index efd5b49..a45210e 100644 --- a/config.yaml +++ b/config.yaml @@ -16,6 +16,9 @@ delLabels: - openeuler-cla - sig - kind +limitMemberSigs: + - Private +limitMemberCnt: 20 lgtmCountsRequired: 1 #Add additional lgtm label quantity limit settings to the organization or repositories #the member variables lcrType indicates whether the setting is for an organization or a repositories, @@ -74,4 +77,4 @@ guideurl: "https://gitee.com/openeuler/community/tree/master/zh/contributors" autoDetectCla: false checkPrReviewer: true #Tips for setting reviewers -setReviewerTip: "Thank you for submitting a PullRequest, but it is detected that you have not set a reviewer, please set a reviewer. " \ No newline at end of file +setReviewerTip: "Thank you for submitting a PullRequest, but it is detected that you have not set a reviewer, please set a reviewer. " diff --git a/pkg/cibot/config/config.go b/pkg/cibot/config/config.go index c0d43a5..06d96d2 100644 --- a/pkg/cibot/config/config.go +++ b/pkg/cibot/config/config.go @@ -11,6 +11,8 @@ type Config struct { DataBasePassword string `yaml:"databasePassword" envVariable:"DATABASE_PASSWORD"` PrUpdateLabelFlag string `yaml:"prUpdateLabelFlag"` DelLabels []string `yaml:"delLabels"` + LimitMemberSigs []string `yaml:"limitMemberSigs"` + LimitMemberCnt int `yaml:"limitMemberCnt"` WatchProjectFiles []WatchProjectFile `yaml:"watchProjectFiles"` WatchProjectFileDuration int `yaml:"watchProjectFileDuration"` WatchSigFiles []WatchSigFile `yaml:"watchSigFiles"` diff --git a/pkg/cibot/pullrequest.go b/pkg/cibot/pullrequest.go index 4c0596d..525f8d5 100644 --- a/pkg/cibot/pullrequest.go +++ b/pkg/cibot/pullrequest.go @@ -38,6 +38,7 @@ func (s *Server) HandlePullRequestEvent(actionDesc string, event *gitee.PullRequ glog.Info("received a pull request open event") // add a tag to describe the sig name of the repo. + limitNotice := false sigName := s.getSigNameFromRepo(event.Repository.FullName) if len(sigName) > 0 { addlabel := &gitee.NoteEvent{} @@ -48,6 +49,11 @@ func (s *Server) HandlePullRequestEvent(actionDesc string, event *gitee.PullRequ if errors != nil { glog.Errorf("Add special label sig info failed: %v", errors) } + for _, limitSig := range s.Config.LimitMemberSigs { + if sigName == limitSig { + limitNotice = true + } + } } @@ -61,8 +67,9 @@ func (s *Server) HandlePullRequestEvent(actionDesc string, event *gitee.PullRequ var committors []string if len(ps) > 0 { for _, p := range ps { - if len(committors) < 20 { - committors = append(committors, fmt.Sprintf("***@%s***", p.User)) + committors = append(committors, fmt.Sprintf("***@%s***", p.User)) + if limitNotice && (len(committors) >= s.Config.LimitMemberCnt) { + break } } } -- Gitee From d3480ac5ea52e2fb707a4d83b5c729cd835392f3 Mon Sep 17 00:00:00 2001 From: georgecao Date: Mon, 15 Nov 2021 17:07:36 +0800 Subject: [PATCH 2/2] Modify init commit when issue submit. --- pkg/cibot/issue.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/cibot/issue.go b/pkg/cibot/issue.go index 97d9d02..162a6cf 100644 --- a/pkg/cibot/issue.go +++ b/pkg/cibot/issue.go @@ -23,6 +23,7 @@ func (s *Server) HandleIssueEvent(event *gitee.IssueEvent) { repo := event.Repository.Path number := event.Issue.Number // get sig name add a tag to describe the sig name of the repo. + limitNotice := false sigName := s.getSigNameFromRepo(event.Repository.FullName) if len(sigName) > 0 { label := []string{fmt.Sprintf("sig/%s", sigName)} @@ -31,6 +32,11 @@ func (s *Server) HandleIssueEvent(event *gitee.IssueEvent) { if error != nil { glog.Errorf("unable to add label in issue: %v", error) } + for _, limitSig := range s.Config.LimitMemberSigs { + if sigName == limitSig { + limitNotice = true + } + } } //get committor list: @@ -43,9 +49,9 @@ func (s *Server) HandleIssueEvent(event *gitee.IssueEvent) { var committors []string if len(ps) > 0 { for _, p := range ps { - if len(committors) < 10 { - committor := fmt.Sprintf("***@%s***", p.User) - committors = append(committors, committor) + committors = append(committors, fmt.Sprintf("***@%s***", p.User)) + if limitNotice && (len(committors) >= s.Config.LimitMemberCnt) { + break } } } -- Gitee