aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/repo/compare.go
diff options
context:
space:
mode:
Diffstat (limited to 'routers/api/v1/repo/compare.go')
-rw-r--r--routers/api/v1/repo/compare.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/routers/api/v1/repo/compare.go b/routers/api/v1/repo/compare.go
index 1678bc033c..87b890cb62 100644
--- a/routers/api/v1/repo/compare.go
+++ b/routers/api/v1/repo/compare.go
@@ -44,13 +44,12 @@ func CompareDiff(ctx *context.APIContext) {
// "$ref": "#/responses/notFound"
if ctx.Repo.GitRepo == nil {
- gitRepo, err := gitrepo.OpenRepository(ctx, ctx.Repo.Repository)
+ var err error
+ ctx.Repo.GitRepo, err = gitrepo.RepositoryFromRequestContextOrOpen(ctx, ctx, ctx.Repo.Repository)
if err != nil {
ctx.Error(http.StatusInternalServerError, "OpenRepository", err)
return
}
- ctx.Repo.GitRepo = gitRepo
- defer gitRepo.Close()
}
infoPath := ctx.PathParam("*")