-3
knotserver/git/git.go
-3
knotserver/git/git.go
+14
-10
knotserver/routes.go
+14
-10
knotserver/routes.go
···
61
62
gr, err := git.Open(path, ref)
63
if err != nil {
64
log.Println(err)
65
if errors.Is(err, plumbing.ErrReferenceNotFound) {
66
resp := types.RepoIndexResponse{
67
-
IsEmpty: true,
68
}
69
writeJSON(w, resp)
70
return
···
461
462
func (h *Handle) Branches(w http.ResponseWriter, r *http.Request) {
463
path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r))
464
-
l := h.l.With("handler", "Branches")
465
466
-
gr, err := git.Open(path, "")
467
if err != nil {
468
notFound(w)
469
return
470
}
471
472
-
branches, err := gr.Branches()
473
-
if err != nil {
474
-
l.Error("getting branches", "error", err.Error())
475
-
writeError(w, err.Error(), http.StatusInternalServerError)
476
-
return
477
-
}
478
479
resp := types.RepoBranchesResponse{
480
Branches: branches,
···
1143
return
1144
}
1145
1146
-
gr, err := git.Open(path, "")
1147
if err != nil {
1148
notFound(w)
1149
return
···
61
62
gr, err := git.Open(path, ref)
63
if err != nil {
64
+
plain, err2 := git.PlainOpen(path)
65
+
if err2 != nil {
66
+
l.Error("opening repo", "error", err2.Error())
67
+
notFound(w)
68
+
return
69
+
}
70
+
branches, _ := plain.Branches()
71
+
72
log.Println(err)
73
+
74
if errors.Is(err, plumbing.ErrReferenceNotFound) {
75
resp := types.RepoIndexResponse{
76
+
IsEmpty: true,
77
+
Branches: branches,
78
}
79
writeJSON(w, resp)
80
return
···
471
472
func (h *Handle) Branches(w http.ResponseWriter, r *http.Request) {
473
path, _ := securejoin.SecureJoin(h.c.Repo.ScanPath, didPath(r))
474
475
+
gr, err := git.PlainOpen(path)
476
if err != nil {
477
notFound(w)
478
return
479
}
480
481
+
branches, _ := gr.Branches()
482
483
resp := types.RepoBranchesResponse{
484
Branches: branches,
···
1147
return
1148
}
1149
1150
+
gr, err := git.PlainOpen(path)
1151
if err != nil {
1152
notFound(w)
1153
return
+4
-4
types/repo.go
+4
-4
types/repo.go
···
49
}
50
51
type TagReference struct {
52
-
Reference `json:"ref,omitempty"`
53
-
Tag *object.Tag `json:"tag,omitempty"`
54
-
Message string `json:"message,omitempty"`
55
}
56
57
type Reference struct {
···
74
}
75
76
type RepoBranchResponse struct {
77
-
Branch Branch `json:"branch,omitempty"`
78
}
79
80
type RepoDefaultBranchResponse struct {
···
49
}
50
51
type TagReference struct {
52
+
Reference
53
+
Tag *object.Tag `json:"tag,omitempty"`
54
+
Message string `json:"message,omitempty"`
55
}
56
57
type Reference struct {
···
74
}
75
76
type RepoBranchResponse struct {
77
+
Branch Branch
78
}
79
80
type RepoDefaultBranchResponse struct {