gitea源码

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2025 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package repo
  4. import (
  5. "net/http"
  6. "code.gitea.io/gitea/modules/templates"
  7. "code.gitea.io/gitea/services/context"
  8. repo_service "code.gitea.io/gitea/services/repository"
  9. )
  10. const tplEditorFork templates.TplName = "repo/editor/fork"
  11. func ForkToEdit(ctx *context.Context) {
  12. ctx.HTML(http.StatusOK, tplEditorFork)
  13. }
  14. func ForkToEditPost(ctx *context.Context) {
  15. ForkRepoTo(ctx, ctx.Doer, repo_service.ForkRepoOptions{
  16. BaseRepo: ctx.Repo.Repository,
  17. Name: getUniqueRepositoryName(ctx, ctx.Doer.ID, ctx.Repo.Repository.Name),
  18. Description: ctx.Repo.Repository.Description,
  19. SingleBranch: ctx.Repo.Repository.DefaultBranch, // maybe we only need the default branch in the fork?
  20. })
  21. if ctx.Written() {
  22. return
  23. }
  24. ctx.JSONRedirect("") // reload the page, the new fork should be editable now
  25. }