gitea创建issue设置 指派成员
This commit is contained in:
@ -269,11 +269,32 @@ func (e *GiteaEvent) PostComments(result *types.ReviewResult) error {
|
|||||||
e.client = newHTTPClient(e.apiBase, e.auth)
|
e.client = newHTTPClient(e.apiBase, e.auth)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取所有提交作者并去重
|
||||||
|
assignees := make(map[string]struct{})
|
||||||
|
for _, commit := range e.Commits {
|
||||||
|
if commit.Author.Login != "" {
|
||||||
|
assignees[commit.Author.Login] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有提交作者,则使用推送者
|
||||||
|
if len(assignees) == 0 {
|
||||||
|
assignees[e.Pusher.Login] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 map 转换为 slice
|
||||||
|
assigneeList := make([]string, 0, len(assignees))
|
||||||
|
for assignee := range assignees {
|
||||||
|
assigneeList = append(assigneeList, assignee)
|
||||||
|
}
|
||||||
|
|
||||||
// 创建 issue
|
// 创建 issue
|
||||||
path := fmt.Sprintf("/api/v1/repos/%s/%s/issues", e.Repository.Owner.Login, e.Repository.Name)
|
path := fmt.Sprintf("/api/v1/repos/%s/%s/issues", e.Repository.Owner.Login, e.Repository.Name)
|
||||||
issueData := map[string]interface{}{
|
issueData := map[string]interface{}{
|
||||||
"title": fmt.Sprintf("AI 代码审查 - %s", e.After[:7]),
|
"title": fmt.Sprintf("AI 代码审查 - %s", e.After[:7]),
|
||||||
"body": utils.FormatReviewResult(result),
|
"body": utils.FormatReviewResult(result),
|
||||||
|
"assignee": assigneeList[0], // 使用第一个作者作为主要受理人
|
||||||
|
"assignees": assigneeList,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := e.client.post(path, issueData); err != nil {
|
if err := e.client.post(path, issueData); err != nil {
|
||||||
@ -281,7 +302,7 @@ func (e *GiteaEvent) PostComments(result *types.ReviewResult) error {
|
|||||||
return fmt.Errorf("创建 issue 失败: %w", err)
|
return fmt.Errorf("创建 issue 失败: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("成功创建 issue: path=%s, commitID=%s", path, e.After[:7])
|
log.Printf("成功创建 issue: path=%s, commitID=%s, assignees=%v", path, e.After[:7], assigneeList)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user