Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7866db7cbb | ||
|
|
ef2bd4ec21 | ||
|
|
ce1d5dd7fe |
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user