diff options
author | Unknwon <u@gogs.io> | 2015-09-02 09:54:35 -0400 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-09-02 09:54:35 -0400 |
commit | d951824ff9c52919e2821d0e9be2504550a994fc (patch) | |
tree | 5fc0d30d17c8999c2e993088a4b6b2df51ac217b /routers | |
parent | 953bb06857f59f5c6987f68a08a94cf5a885b456 (diff) | |
download | gitea-d951824ff9c52919e2821d0e9be2504550a994fc.tar.gz gitea-d951824ff9c52919e2821d0e9be2504550a994fc.zip |
able to download archive by API
Diffstat (limited to 'routers')
-rw-r--r-- | routers/api/v1/repo_file.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/routers/api/v1/repo_file.go b/routers/api/v1/repo_file.go index 73f97b2cae..540cd32fa8 100644 --- a/routers/api/v1/repo_file.go +++ b/routers/api/v1/repo_file.go @@ -5,6 +5,7 @@ package v1 import ( + "github.com/gogits/gogs/models" "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/git" "github.com/gogits/gogs/modules/middleware" @@ -30,3 +31,15 @@ func GetRepoRawFile(ctx *middleware.Context) { ctx.JSON(500, &base.ApiJsonErr{"ServeBlob: " + err.Error(), base.DOC_URL}) } } + +func GetRepoArchive(ctx *middleware.Context) { + repoPath := models.RepoPath(ctx.Params(":username"), ctx.Params(":reponame")) + gitRepo, err := git.OpenRepository(repoPath) + if err != nil { + ctx.Handle(500, "RepoAssignment Invalid repo: "+repoPath, err) + return + } + ctx.Repo.GitRepo = gitRepo + + repo.Download(ctx) +} |