summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
author无闻 <joe2010xtmf@163.com>2014-10-18 23:59:36 -0400
committer无闻 <joe2010xtmf@163.com>2014-10-18 23:59:36 -0400
commitd7d167ac63e0ada717f78383016f5b208a1b209a (patch)
treeb341240313a833311299ccd1594f3b92a4d44c1e /routers
parent146c8efee3d01e220aa8f8554b69b6f76a0820e4 (diff)
parent8d2a6fc484b540819e211d52b8d54e97269f0918 (diff)
downloadgitea-d7d167ac63e0ada717f78383016f5b208a1b209a.tar.gz
gitea-d7d167ac63e0ada717f78383016f5b208a1b209a.zip
Merge pull request #560 from evolvedlight/master
First cut of fork repo
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/repo.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go
index 5562a8400a..8b18eb25bf 100644
--- a/routers/repo/repo.go
+++ b/routers/repo/repo.go
@@ -217,6 +217,21 @@ func Action(ctx *middleware.Context) {
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, true)
case "unstar":
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.Id, false)
+ case "fork":
+ repo, error := models.ForkRepository(ctx.User, ctx.Repo.Repository)
+ if error != nil {
+ log.Error(4, "Action(%s): %v", ctx.Params(":action"), error)
+ ctx.JSON(200, map[string]interface{}{
+ "ok": false,
+ "err": error.Error(),
+ })
+ return
+ }
+ if error == nil {
+ ctx.Redirect(setting.AppSubUrl + "/" + repo.Owner.Name + "/" + repo.Name)
+
+ return
+ }
case "desc":
if !ctx.Repo.IsOwner {
ctx.Error(404)