diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-10-19 01:35:24 -0400 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-10-19 01:35:24 -0400 |
commit | a342d58d7e208ef64d29151970244de7f7b4fac6 (patch) | |
tree | 55972233ac1517513d865dc2ba4895b7cdaf95cb /routers/repo/repo.go | |
parent | d7d167ac63e0ada717f78383016f5b208a1b209a (diff) | |
download | gitea-a342d58d7e208ef64d29151970244de7f7b4fac6.tar.gz gitea-a342d58d7e208ef64d29151970244de7f7b4fac6.zip |
Able to fork repo to individuals
Diffstat (limited to 'routers/repo/repo.go')
-rw-r--r-- | routers/repo/repo.go | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 8b18eb25bf..2116e2c9fc 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -217,21 +217,20 @@ 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 "fork": + repo, err := models.ForkRepository(ctx.User, ctx.Repo.Repository) + if err != nil { + if err != models.ErrRepoAlreadyExist { + log.Error(4, "Action(%s): %v", ctx.Params(":action"), err) + ctx.JSON(200, map[string]interface{}{ + "ok": false, + "err": err.Error(), + }) + return + } + } + ctx.Redirect(setting.AppSubUrl + "/" + repo.Owner.Name + "/" + repo.Name) + return case "desc": if !ctx.Repo.IsOwner { ctx.Error(404) |