Compare commits

...
3 Commits
Author SHA1 Message Date
wonder 7866db7cbb 🔧Chore: 增加日志 2025-10-13 15:07:26 +08:00
wonder ef2bd4ec21 🐛Fix: 修复缺失的响应头 2025-10-13 15:05:07 +08:00
wonder ce1d5dd7fe ✨Feat: 获取文件修改 2025-10-13 15:02:00 +08:00
3 changed files with 28 additions and 2 deletions
@@ -23,7 +23,8 @@ public class HookController {
@PostMapping
public ResponseEntity<String> handlePush(@RequestBody GiteaPushEvent event) {
log.info(event.toString());
log.info("\n============================\n");
hookService.handlePush(event);
return ResponseEntity.ok().build();
return ResponseEntity.ok("Ciallo~(∠・ω< )⌒★");
}
}
@@ -6,7 +6,6 @@ import java.util.List;
@Data
public class GiteaPushEvent {
private String secret;
private String ref;
private String before;
private String after;
@@ -35,6 +34,9 @@ public class GiteaPushEvent {
private User author;
private User committer;
private String timestamp;
private List<String> added;
private List<String> removed;
private List<String> modified;
}
@Data
@@ -3,17 +3,40 @@ package cn.hezhaohui.webhook.service;
import cn.hezhaohui.lark.entity.CardData;
import cn.hezhaohui.lark.util.Lark;
import cn.hezhaohui.webhook.entity.GiteaPushEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Stream;
@Service
@Slf4j
public class HookService {
public void handlePush(GiteaPushEvent event) {
List<String> commitMsgList = event.getCommits().stream()
.map(GiteaPushEvent.Commit::getMessage)
.toList();
List<String> addedFiles = event.getCommits().stream()
.flatMap(commit -> commit.getAdded().stream())
.toList();
List<String> removedFiles = event.getCommits().stream()
.flatMap(commit -> commit.getRemoved().stream())
.toList();
List<String> modifiedFiles = event.getCommits().stream()
.flatMap(commit -> commit.getModified().stream())
.toList();
log.info("commitMsgList: {}\n", commitMsgList);
log.info("addedFiles: {}\n", addedFiles);
log.info("removedFiles: {}\n", removedFiles);
log.info("modifiedFiles: {}\n", modifiedFiles);
// TODO: 调用 AI 模块
CardData cardData = CardData.builder()
.title("[Gitea] 仓库状态变化")
.repo(event.getRepository().getName())