diff --git a/README.md b/README.md index 23b07591f0bf18aeb656a3982b2925150a450a94..6cade185fe7616f78ecf7e0e8cea1f68f46de88b 100644 --- a/README.md +++ b/README.md @@ -63,3 +63,5 @@ See the [Command Help](https://gitee.com/openeuler/community/blob/master/en/sig- See the [LICENSE](LICENSE) file for details. + + diff --git a/pkg/cibot/frozenhandler.go b/pkg/cibot/frozenhandler.go index c7cd0ddac56c00b91ed047dfd4614a73a4410d2f..003eb388d5406d45f43f50bd48936b02f166d44f 100644 --- a/pkg/cibot/frozenhandler.go +++ b/pkg/cibot/frozenhandler.go @@ -35,9 +35,10 @@ type FrozenYaml struct { //FrozenBranchYaml Branch freeze configuration type FrozenBranchYaml struct { - Branch string `yaml:"branch"` - Frozen bool `yaml:"frozen"` - Owner []string `yaml:"owner"` + Branch string `yaml:"branch"` + Frozen bool `yaml:"frozen"` + Owner []string `yaml:"owner"` + Communtiy []string `yaml:"community"` } var @@ -170,6 +171,7 @@ func emptyFrozenList() { frozenFile = freezeFile{} } lock.Unlock() + glog.Info("FrozenList after empty: %v", frozenList) } func writeFrozenList(fs []FrozenBranchYaml) { @@ -179,17 +181,25 @@ func writeFrozenList(fs []FrozenBranchYaml) { frozenList = frozenList[:0] } frozenList = append(frozenList, fs...) + glog.Info("FrozenList after write: %v", frozenList) } //IsBranchFrozen Check if the branch is frozen -func IsBranchFrozen(branch string) (owner []string, isFrozen bool) { +func IsBranchFrozen(branch string, community string) (owner []string, isFrozen bool) { lock.RLock() defer lock.RUnlock() if len(frozenList) == 0 { return nil, isFrozen } for _, v := range frozenList { - if v.Branch == branch { + var isCommunityFrozen = false + for _, c := range v.Communtiy { + if c == community { + isCommunityFrozen = true + break + } + } + if v.Branch == branch && isCommunityFrozen{ isFrozen = true owner = append(owner, v.Owner...) break diff --git a/pkg/cibot/issue.go b/pkg/cibot/issue.go index f16a737725ee46ac03b5836639e46a25bded841e..04e7d9e3792dc6a76c24ca82de43acbba1e99103 100644 --- a/pkg/cibot/issue.go +++ b/pkg/cibot/issue.go @@ -35,8 +35,9 @@ func (s *Server) HandleIssueEvent(event *gitee.IssueEvent) { if err != nil { glog.Errorf("unable to add comment in issue: %v", err) } - sigName := s.getSigNameFromRepo(event.Repository.FullName) - if len(sigName) > 0 { + + sigName := s.getSigNameFromRepo(event.Repository.FullName) + if len(sigName) > 0 { label := []string{fmt.Sprintf("sig/%s", sigName)} labelops := gitee.PullRequestLabelPostParam{s.Config.GiteeToken, label} _, _, err = s.GiteeClient.LabelsApi.PostV5ReposOwnerRepoIssuesNumberLabels(s.Context, owner, repo, number, labelops) diff --git a/pkg/cibot/pullrequest.go b/pkg/cibot/pullrequest.go index 35d3a4c4599ddb2ccc9d685a521c1622de0f4ecc..6a79ba9e8169668ed528ddf937be2d68869c6da6 100644 --- a/pkg/cibot/pullrequest.go +++ b/pkg/cibot/pullrequest.go @@ -488,7 +488,7 @@ func (s *Server) MergePullRequest(event *gitee.NoteEvent) error { nonRequiringLabels, nonMissingLabels := s.legalLabelsForMerge(listofPrLabels) if len(nonRequiringLabels) == 0 && len(nonMissingLabels) == 0 { // current pr can be merged - if c, b := checkFrozenCanMerge(event.Author.Login, pr.Base.Ref); !b { + if c, b := checkFrozenCanMerge(event.Author.Login, pr.Base.Ref, owner); !b { //send comment to pr comment := "" if len(c) > 0 { @@ -625,8 +625,8 @@ func getSignersAndReviewers(user string, comments []gitee.PullRequestComments) ( return signers, reviewers, nil } -func checkFrozenCanMerge(commenter, branch string) ([]string, bool) { - frozen, isFrozen := IsBranchFrozen(branch) +func checkFrozenCanMerge(commenter, branch string, community string) ([]string, bool) { + frozen, isFrozen := IsBranchFrozen(branch, community) if isFrozen { canMerge := false for _, v := range frozen {