代码拉取完成,页面将自动刷新
package cibot
import (
"fmt"
"strings"
"gitee.com/openeuler/ci-bot/pkg/cibot/database"
"gitee.com/openeuler/go-gitee/gitee"
"github.com/golang/glog"
)
// HandleIssueEvent handles issue event
func (s *Server) HandleIssueEvent(event *gitee.IssueEvent) {
if event == nil {
return
}
// handle events
switch *event.Action {
case "open":
glog.Info("received a issue open event")
owner := event.Repository.Namespace
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)}
labelops := gitee.PullRequestLabelPostParam{s.Config.GiteeToken, label}
_, _, error := s.GiteeClient.LabelsApi.PostV5ReposOwnerRepoIssuesNumberLabels(s.Context, owner, repo, number, labelops)
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:
var ps []database.Privileges
err := database.DBConnection.Model(&database.Privileges{}).
Where("owner = ? and repo = ? and type = ?", owner, repo, PrivilegeDeveloper).Find(&ps).Error
if err != nil {
glog.Errorf("unable to get members: %v", err)
}
var committors []string
if len(ps) > 0 {
for _, p := range ps {
committors = append(committors, fmt.Sprintf("***@%s***", p.User))
if limitNotice && (len(committors) >= s.Config.LimitMemberCnt) {
break
}
}
}
committor_list := strings.Join(committors, ", ")
if len(committor_list) > 0 {
sigPath := fmt.Sprintf(SigPath, sigName)
proInfo := fmt.Sprintf(DisplayCommittors, sigName, sigPath)
committor_list = proInfo + committor_list + "."
}
// add comment
body := gitee.IssueCommentPostParam{}
body.AccessToken = s.Config.GiteeToken
body.Body = fmt.Sprintf(tipBotMessage, event.Sender.Login, s.Config.CommunityName, s.Config.CommandLink, committor_list)
//Issue could exists without belonging to any repo.
if event.Repository == nil {
glog.Warningf("Issue is not created on repo, skip posting issue comment.")
return
}
_, _, err = s.GiteeClient.IssuesApi.PostV5ReposOwnerRepoIssuesNumberComments(s.Context, owner, repo, number, body)
if err != nil {
glog.Errorf("unable to add comment in issue: %v", err)
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。