mirror of
https://github.com/go-gitea/gitea
synced 2024-12-24 03:35:55 +01:00
able to download archive by API
This commit is contained in:
parent
953bb06857
commit
d951824ff9
@ -243,6 +243,7 @@ func runWeb(ctx *cli.Context) {
|
|||||||
Post(bind(api.CreateHookOption{}), v1.CreateRepoHook)
|
Post(bind(api.CreateHookOption{}), v1.CreateRepoHook)
|
||||||
m.Patch("/hooks/:id:int", bind(api.EditHookOption{}), v1.EditRepoHook)
|
m.Patch("/hooks/:id:int", bind(api.EditHookOption{}), v1.EditRepoHook)
|
||||||
m.Get("/raw/*", middleware.RepoRef(), v1.GetRepoRawFile)
|
m.Get("/raw/*", middleware.RepoRef(), v1.GetRepoRawFile)
|
||||||
|
m.Get("/archive/*", v1.GetRepoArchive)
|
||||||
}, middleware.ApiRepoAssignment(), middleware.ApiReqToken())
|
}, middleware.ApiRepoAssignment(), middleware.ApiReqToken())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package v1
|
package v1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/gogits/gogs/models"
|
||||||
"github.com/gogits/gogs/modules/base"
|
"github.com/gogits/gogs/modules/base"
|
||||||
"github.com/gogits/gogs/modules/git"
|
"github.com/gogits/gogs/modules/git"
|
||||||
"github.com/gogits/gogs/modules/middleware"
|
"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})
|
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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user