summaryrefslogtreecommitdiffstats
path: root/modules/middleware/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/middleware/repo.go')
-rw-r--r--modules/middleware/repo.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/middleware/repo.go b/modules/middleware/repo.go
index d01f93fa4c..2d311d2131 100644
--- a/modules/middleware/repo.go
+++ b/modules/middleware/repo.go
@@ -122,6 +122,17 @@ func RepoRef() macaron.Handler {
err error
)
+ // For API calls.
+ if ctx.Repo.GitRepo == nil {
+ repoPath := models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
+ gitRepo, err := git.OpenRepository(repoPath)
+ if err != nil {
+ ctx.Handle(500, "RepoRef Invalid repo "+repoPath, err)
+ return
+ }
+ ctx.Repo.GitRepo = gitRepo
+ }
+
// Get default branch.
if len(ctx.Params("*")) == 0 {
refName = ctx.Repo.Repository.DefaultBranch