forked from forgejo/forgejo
[FEAT]: Allow forking without a repo ID
Forking a repository via the web UI currently requires visiting a `/repo/fork/{{repoid}}` URL. This makes it cumbersome to create a link that starts a fork, because the repository ID is only available via the API. While it *is* possible to create a link, doing so requires extra steps. To make it easier to have a "Fork me!"-style links, introduce the `/{username}/{repo}/fork` route, which will start the forking process based on the repository in context instead. The old `/repo/fork/{repoid}` route (with a `GET` request) will remain there for the sake of backwards compatibility, but will redirect to the new URL instead. It's `POST` handler is removed. Tests that used the old route are updated to use the new one, and new tests are introduced to exercise the redirect. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
This commit is contained in:
parent
cf1c57b681
commit
f8da672307
4 changed files with 130 additions and 48 deletions
|
@ -967,10 +967,7 @@ func registerRoutes(m *web.Route) {
|
|||
m.Post("/create", web.Bind(forms.CreateRepoForm{}), repo.CreatePost)
|
||||
m.Get("/migrate", repo.Migrate)
|
||||
m.Post("/migrate", web.Bind(forms.MigrateRepoForm{}), repo.MigratePost)
|
||||
m.Group("/fork", func() {
|
||||
m.Combo("/{repoid}").Get(repo.Fork).
|
||||
Post(web.Bind(forms.CreateRepoForm{}), repo.ForkPost)
|
||||
}, context.RepoIDAssignment(), context.UnitTypes(), reqRepoCodeReader)
|
||||
m.Get("/fork/{repoid}", context.RepoIDAssignment(), context.UnitTypes(), reqRepoCodeReader, repo.ForkByID)
|
||||
m.Get("/search", repo.SearchRepo)
|
||||
}, reqSignIn)
|
||||
|
||||
|
@ -1148,6 +1145,8 @@ func registerRoutes(m *web.Route) {
|
|||
|
||||
// Grouping for those endpoints that do require authentication
|
||||
m.Group("/{username}/{reponame}", func() {
|
||||
m.Combo("/fork", reqRepoCodeReader).Get(repo.Fork).
|
||||
Post(web.Bind(forms.CreateRepoForm{}), repo.ForkPost)
|
||||
m.Group("/issues", func() {
|
||||
m.Group("/new", func() {
|
||||
m.Combo("").Get(context.RepoRef(), repo.NewIssue).
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue