diff options
author | Unknwon <u@gogs.io> | 2015-11-18 19:32:23 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-11-18 19:32:23 -0500 |
commit | 2c653141a83eb5bc3fb1baaff0449195b9e1f6a6 (patch) | |
tree | 4aab191a53427da0c17a58d42ef01e2f1b28c550 /routers/repo | |
parent | f04d773f4f72f8f167b7ceed4d4e9a6fd4e6ad16 (diff) | |
download | gitea-2c653141a83eb5bc3fb1baaff0449195b9e1f6a6.tar.gz gitea-2c653141a83eb5bc3fb1baaff0449195b9e1f6a6.zip |
#1742 Update default branch in git repository while change in web view
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/setting.go | 9 |
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 |