git-sync-web 自动提交 2026-09-09 18:02:17

This commit is contained in:
tamakyi
2026-09-09 18:02:18 +08:00
parent b260720183
commit de2295bb5f
6 changed files with 381 additions and 10 deletions
+24
View File
@@ -53,6 +53,8 @@ func NewServer(e *Engine, static fs.FS, password string) *Server {
mux.HandleFunc("GET /api/repos/{name}/tree", s.wrapRepo(s.treeRepo))
mux.HandleFunc("GET /api/repos/{name}/file", s.wrapRepo(s.fileRepo))
mux.HandleFunc("PUT /api/repos/{name}/file", s.wrapRepo(s.fileWriteRepo))
mux.HandleFunc("GET /api/repos/{name}/summary", s.wrapRepo(s.summaryGetRepo))
mux.HandleFunc("POST /api/repos/{name}/summary", s.wrapRepo(s.summarySaveRepo))
mux.HandleFunc("POST /api/repos/{name}/resolve-file", s.wrapRepo(s.resolveFileRepo))
mux.HandleFunc("POST /api/repos/{name}/commit", s.wrapRepo(s.commitFileRepo))
mux.HandleFunc("GET /api/repos/{name}/diff", s.wrapRepo(s.diffRepo))
@@ -376,6 +378,28 @@ func (s *Server) fileWriteRepo(w http.ResponseWriter, r *http.Request, name stri
writeJSON(w, 200, map[string]any{"ok": true})
}
func (s *Server) summaryGetRepo(w http.ResponseWriter, r *http.Request, name string) {
writeJSON(w, 200, map[string]any{
"pending": s.engine.GetPendingSummary(name),
"log": s.engine.GetSummaryLog(name),
})
}
func (s *Server) summarySaveRepo(w http.ResponseWriter, r *http.Request, name string) {
var req struct {
Summary string `json:"summary"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
writeErr(w, 400, "请求体格式错误")
return
}
if err := s.engine.SavePendingSummary(name, req.Summary); err != nil {
writeErr(w, 500, err.Error())
return
}
writeJSON(w, 200, map[string]any{"ok": true, "pending": s.engine.GetPendingSummary(name)})
}
func (s *Server) resolveFileRepo(w http.ResponseWriter, r *http.Request, name string) {
var req struct {
Path string `json:"path"`