Browse Source

inlined fork method

pull/1630/head
Kim Lindhardt Madsen 9 years ago
parent
commit
43d7c4709f
  1. 1
      cmd/web.go
  2. 8
      routers/api/v1/repo.go

1
cmd/web.go

@ -242,6 +242,7 @@ func runWeb(ctx *cli.Context) {
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) m.Get("/archive/*", v1.GetRepoArchive)
m.Post("/forks", v1.ForkRepo)
}, middleware.ApiRepoAssignment(), middleware.ApiReqToken()) }, middleware.ApiRepoAssignment(), middleware.ApiReqToken())
}) })

8
routers/api/v1/repo.go

@ -192,11 +192,7 @@ func CreateOrgRepo(ctx *middleware.Context, opt api.CreateRepoOption) {
} }
func ForkRepo(ctx *middleware.Context) { func ForkRepo(ctx *middleware.Context) {
forkRepo(ctx, ctx.User, ctx.Repo.Repository) forkedRepo, err := models.ForkRepository(ctx.User, ctx.Repo.Repository, ctx.Repo.Repository.Name, ctx.Repo.Repository.Description)
}
func forkRepo(ctx *middleware.Context, owner *models.User, repo *models.Repository) {
forkedRepo, err := models.ForkRepository(owner, repo, repo.Name, repo.Description)
if err != nil { if err != nil {
if models.IsErrRepoAlreadyExist(err) || if models.IsErrRepoAlreadyExist(err) ||
models.IsErrNameReserved(err) || models.IsErrNameReserved(err) ||
@ -214,7 +210,7 @@ func forkRepo(ctx *middleware.Context, owner *models.User, repo *models.Reposito
return return
} }
ctx.JSON(201, ToApiRepository(owner, forkedRepo, api.Permission{true, true, true})) ctx.JSON(201, ToApiRepository(ctx.User, forkedRepo, api.Permission{true, true, true}))
} }
func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) { func MigrateRepo(ctx *middleware.Context, form auth.MigrateRepoForm) {

Loading…
Cancel
Save