summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
Diffstat (limited to 'routers')
-rw-r--r--routers/repo/setting.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go
index bee29254c5..019949b793 100644
--- a/routers/repo/setting.go
+++ b/routers/repo/setting.go
@@ -80,8 +80,15 @@ func SettingsPost(ctx *middleware.Context, form auth.RepoSettingForm) {
repo.Name = newRepoName
repo.LowerName = strings.ToLower(newRepoName)
- if ctx.Repo.GitRepo.IsBranchExist(form.Branch) {
+ if ctx.Repo.GitRepo.IsBranchExist(form.Branch) &&
+ repo.DefaultBranch != form.Branch {
repo.DefaultBranch = form.Branch
+ if err := ctx.Repo.GitRepo.SetDefaultBranch(form.Branch); err != nil {
+ if !git.IsErrUnsupportedVersion(err) {
+ ctx.Handle(500, "SetDefaultBranch", err)
+ return
+ }
+ }
}
repo.Description = form.Description
repo.Website = form.Website