diff options
Diffstat (limited to 'routers/api/v1/utils/git.go')
-rw-r--r-- | routers/api/v1/utils/git.go | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/routers/api/v1/utils/git.go b/routers/api/v1/utils/git.go index 9f02bc8083..ac64d5b87b 100644 --- a/routers/api/v1/utils/git.go +++ b/routers/api/v1/utils/git.go @@ -5,6 +5,7 @@ package utils import ( + "fmt" "net/http" "code.gitea.io/gitea/modules/context" @@ -35,12 +36,7 @@ func ResolveRefOrSha(ctx *context.APIContext, ref string) string { // GetGitRefs return git references based on filter func GetGitRefs(ctx *context.APIContext, filter string) ([]*git.Reference, string, error) { if ctx.Repo.GitRepo == nil { - var err error - ctx.Repo.GitRepo, err = git.OpenRepository(ctx, ctx.Repo.Repository.RepoPath()) - if err != nil { - return nil, "OpenRepository", err - } - defer ctx.Repo.GitRepo.Close() + return nil, "", fmt.Errorf("no open git repo found in context") } if len(filter) > 0 { filter = "refs/" + filter |