#1742 Update default branch in git repository while change in web view

This commit is contained in:
Unknwon 2015-11-18 19:32:23 -05:00
parent f04d773f4f
commit 2c653141a8
7 changed files with 47 additions and 4 deletions

View file

@ -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