diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-11-16 21:32:26 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-11-16 21:32:26 -0500 |
commit | a0f9197b4573aa9d4d868637ed00e710a435797b (patch) | |
tree | 41efdcb5813cdb1a66bd1fc3bc5c86a371c7815b /modules/middleware | |
parent | 340a4595ddc9e08f4c51f40496affb8fd3bb013d (diff) | |
download | gitea-a0f9197b4573aa9d4d868637ed00e710a435797b.tar.gz gitea-a0f9197b4573aa9d4d868637ed00e710a435797b.zip |
GetFile api
Diffstat (limited to 'modules/middleware')
-rw-r--r-- | modules/middleware/repo.go | 11 |
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 |