A vibe coded tangled fork which supports pijul.
at master 44 lines 1.0 kB view raw
1package xrpc 2 3import ( 4 "net/http" 5 "time" 6 7 "tangled.org/core/api/tangled" 8 "tangled.org/core/knotserver/vcs" 9 xrpcerr "tangled.org/core/xrpc/errors" 10) 11 12func (x *Xrpc) RepoGetDefaultBranch(w http.ResponseWriter, r *http.Request) { 13 repo := r.URL.Query().Get("repo") 14 repoPath, err := x.parseRepoParam(repo) 15 if err != nil { 16 writeError(w, err.(xrpcerr.XrpcError), http.StatusBadRequest) 17 return 18 } 19 20 rv, err := vcs.PlainOpen(repoPath) 21 if err != nil { 22 x.Logger.Error("failed to open repository", "error", err) 23 writeError(w, xrpcerr.RepoNotFoundError, http.StatusNoContent) 24 return 25 } 26 27 branch, err := rv.DefaultBranch() 28 if err != nil { 29 x.Logger.Error("getting default branch", "error", err.Error()) 30 writeError(w, xrpcerr.NewXrpcError( 31 xrpcerr.WithTag("InvalidRequest"), 32 xrpcerr.WithMessage("failed to get default branch"), 33 ), http.StatusInternalServerError) 34 return 35 } 36 37 response := tangled.RepoGetDefaultBranch_Output{ 38 Name: branch, 39 Hash: "", 40 When: time.UnixMicro(0).Format(time.RFC3339), 41 } 42 43 writeJson(w, response) 44}