diff --git a/routers/hat/hat.go b/routers/hat/hat.go index d6285cc..31cc2ae 100644 --- a/routers/hat/hat.go +++ b/routers/hat/hat.go @@ -71,7 +71,7 @@ func Routers(ctx gocontext.Context) *web.Route { m.Get("/tag_name_set", context.ReferencesGitRepo(), repo.TagNameSet) m.Get("/branch_tag_count", context.ReferencesGitRepo(), repo.BranchTagCount) m.Group("/branches", func() { - m.Get("", repo.ListBranches) + m.Get("", context.ReferencesGitRepo(), repo.ListBranches) m.Get("/branches_slice", context.ReferencesGitRepo(), repo.ListBranchesSlice) }, reqRepoReader(unit_model.TypeCode)) m.Group("/commits", func() { diff --git a/routers/hat/repo/branch.go b/routers/hat/repo/branch.go index bb2f192..f160983 100644 --- a/routers/hat/repo/branch.go +++ b/routers/hat/repo/branch.go @@ -30,9 +30,9 @@ func ListBranches(ctx *context.APIContext) { apiBranches := make([]*gitea_api.Branch, len(branches)) for i := range branches { - c, err := branches[i].GetCommit() + c, err := ctx.Repo.GitRepo.GetBranchCommit(branches[i].Name) if err != nil { - ctx.Error(http.StatusInternalServerError, "GetCommit", err) + ctx.Error(http.StatusInternalServerError, "GetBranchCommit", err) return } branchProtection, err := git_model.GetProtectedBranchBy(ctx, ctx.Repo.Repository.ID, branches[i].Name)