gitea获取diff更改 dockerfile更改 日志输出至文件
This commit is contained in:
@ -62,11 +62,29 @@ func (e *GitlabEvent) ExtractChanges() (*types.CodeChanges, error) {
|
||||
}
|
||||
|
||||
// 检查是否跳过代码审查
|
||||
validCommits := make([]struct {
|
||||
ID string `json:"id"`
|
||||
Message string `json:"message"`
|
||||
Title string `json:"title"`
|
||||
}, 0)
|
||||
|
||||
for _, commit := range e.Commits {
|
||||
if strings.Contains(commit.Message, "[skip codereview]") {
|
||||
log.Printf("跳过代码审查: commit=%s", commit.ID)
|
||||
return nil, nil
|
||||
}
|
||||
// 过滤合并提交
|
||||
if strings.HasPrefix(commit.Message, "Merge remote-tracking branch") ||
|
||||
strings.HasPrefix(commit.Message, "Merge branch") {
|
||||
log.Printf("跳过合并提交: commit=%s", commit.ID)
|
||||
continue
|
||||
}
|
||||
validCommits = append(validCommits, commit)
|
||||
}
|
||||
|
||||
if len(validCommits) == 0 {
|
||||
log.Printf("没有有效的提交记录(所有提交都是合并提交),跳过代码审查")
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
if e.client == nil {
|
||||
@ -81,7 +99,7 @@ func (e *GitlabEvent) ExtractChanges() (*types.CodeChanges, error) {
|
||||
Files: make([]types.FileChange, 0),
|
||||
}
|
||||
|
||||
for _, commit := range e.Commits {
|
||||
for _, commit := range validCommits {
|
||||
// 移除 URL 中的 token
|
||||
apiPath := fmt.Sprintf("/api/v4/projects/%d/repository/commits/%s/diff",
|
||||
e.Project.ID, commit.ID)
|
||||
|
Reference in New Issue
Block a user