修复:gitrepo nil 问题

This commit is contained in:
yystopf 2023-02-23 13:57:38 +08:00
parent 4df80116dc
commit ab66f7a4de
2 changed files with 3 additions and 3 deletions

View File

@ -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() {

View File

@ -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)