From 52cfd2743c0e85b36081cf80a850e6a5901f1865 Mon Sep 17 00:00:00 2001 From: zeripath Date: Thu, 26 Mar 2020 19:14:51 +0000 Subject: Option to set default branch at repository creation (#10803) * Option to set default branch at repository creation * Handle template repos with non-default master branch * Add DefaultBranch handling on creation to API Fix #9542 Signed-off-by: Andrew Thornton --- routers/api/v1/repo/repo.go | 17 +++++++++-------- routers/repo/repo.go | 17 +++++++++-------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'routers') diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 047d8168b3..5eeef9fb9d 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -218,14 +218,15 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR opt.Readme = "Default" } repo, err := repo_service.CreateRepository(ctx.User, owner, models.CreateRepoOptions{ - Name: opt.Name, - Description: opt.Description, - IssueLabels: opt.IssueLabels, - Gitignores: opt.Gitignores, - License: opt.License, - Readme: opt.Readme, - IsPrivate: opt.Private, - AutoInit: opt.AutoInit, + Name: opt.Name, + Description: opt.Description, + IssueLabels: opt.IssueLabels, + Gitignores: opt.Gitignores, + License: opt.License, + Readme: opt.Readme, + IsPrivate: opt.Private, + AutoInit: opt.AutoInit, + DefaultBranch: opt.DefaultBranch, }) if err != nil { if models.IsErrRepoAlreadyExist(err) { diff --git a/routers/repo/repo.go b/routers/repo/repo.go index 5177add99c..3f135dd216 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -221,14 +221,15 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) { } } else { repo, err = repo_service.CreateRepository(ctx.User, ctxUser, models.CreateRepoOptions{ - Name: form.RepoName, - Description: form.Description, - Gitignores: form.Gitignores, - IssueLabels: form.IssueLabels, - License: form.License, - Readme: form.Readme, - IsPrivate: form.Private || setting.Repository.ForcePrivate, - AutoInit: form.AutoInit, + Name: form.RepoName, + Description: form.Description, + Gitignores: form.Gitignores, + IssueLabels: form.IssueLabels, + License: form.License, + Readme: form.Readme, + IsPrivate: form.Private || setting.Repository.ForcePrivate, + DefaultBranch: form.DefaultBranch, + AutoInit: form.AutoInit, }) if err == nil { log.Trace("Repository created [%d]: %s/%s", repo.ID, ctxUser.Name, repo.Name) -- cgit v1.2.3