diff options
author | Dmitry Sharshakov <d3dx12.xx@gmail.com> | 2023-09-29 04:48:39 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-29 09:48:39 +0800 |
commit | 5e02e3b7ee8294e2ec94968ece9af56bf1aa1534 (patch) | |
tree | 038e8619ee6b08b0c9ebd9be183ba190a1bc27f2 /routers | |
parent | e8840e7e2b6c4eaf6fa78dad49a29709ef35217b (diff) | |
download | gitea-5e02e3b7ee8294e2ec94968ece9af56bf1aa1534.tar.gz gitea-5e02e3b7ee8294e2ec94968ece9af56bf1aa1534.zip |
Add support for forking single branch (#25821)
Fixes #25117
Add UI for choosing branch to fork
Change default branch on single-branch forks

---------
Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/pull.go | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 63dfd0f7b5..6e69811901 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -180,6 +180,21 @@ func getForkRepository(ctx *context.Context) *repo_model.Repository { return nil } + branches, err := git_model.FindBranchNames(ctx, git_model.FindBranchOptions{ + RepoID: ctx.Repo.Repository.ID, + ListOptions: db.ListOptions{ + ListAll: true, + }, + IsDeletedBranch: util.OptionalBoolFalse, + // Add it as the first option + ExcludeBranchNames: []string{ctx.Repo.Repository.DefaultBranch}, + }) + if err != nil { + ctx.ServerError("FindBranchNames", err) + return nil + } + ctx.Data["Branches"] = append([]string{ctx.Repo.Repository.DefaultBranch}, branches...) + return forkRepo } @@ -261,9 +276,10 @@ func ForkPost(ctx *context.Context) { } repo, err := repo_service.ForkRepository(ctx, ctx.Doer, ctxUser, repo_service.ForkRepoOptions{ - BaseRepo: forkRepo, - Name: form.RepoName, - Description: form.Description, + BaseRepo: forkRepo, + Name: form.RepoName, + Description: form.Description, + SingleBranch: form.ForkSingleBranch, }) if err != nil { ctx.Data["Err_RepoName"] = true |