Ai
13 Star 25 Fork 28

openEuler/ci-bot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
checkpr.go 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
xwzQmxx 提交于 2020-11-27 15:30 +08:00 . fix issue I275ZO
package cibot
import (
"gitee.com/openeuler/go-gitee/gitee"
"github.com/golang/glog"
)
var checkPrComment = "Cannot use \"/check-pr\", because this command is only used to detect open pull requests"
//CheckPr Check whether the pull request can be merged
func (s *Server) CheckPr(event *gitee.NoteEvent) (err error) {
if *event.NoteableType == "PullRequest" && event.PullRequest.State == "open" {
err := s.MergePullRequest(event)
if err != nil {
comment := err.Error()
return s.addCommentToPullRequest(event.Repository.Namespace, event.Repository.Name,
comment, event.PullRequest.Number)
}
} else {
return s.addCommentToPullRequest(event.Repository.Namespace, event.Repository.Name,
checkPrComment, event.PullRequest.Number)
}
return nil
}
func (s *Server) addCommentToPullRequest(owner, repo, comment string, number int32) error {
body := gitee.PullRequestCommentPostParam{}
body.AccessToken = s.Config.GiteeToken
body.Body = comment
_, _, err := s.GiteeClient.PullRequestsApi.PostV5ReposOwnerRepoPullsNumberComments(s.Context, owner, repo, number, body)
if err != nil {
glog.Errorf("unable to add comment in pull request: %v", err)
return err
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/openeuler/ci-bot.git
git@gitee.com:openeuler/ci-bot.git
openeuler
ci-bot
ci-bot
e91f82195b70

搜索帮助