|
|
|
|
@ -736,14 +736,14 @@ func updateBasicProperties(ctx *context.APIContext, opts api.EditRepoOption) err
|
|
|
|
|
// Default branch only updated if changed and exist or the repository is empty
|
|
|
|
|
updateRepoLicense := false
|
|
|
|
|
if opts.DefaultBranch != nil && repo.DefaultBranch != *opts.DefaultBranch && (repo.IsEmpty || gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, *opts.DefaultBranch)) {
|
|
|
|
|
repo.DefaultBranch = *opts.DefaultBranch
|
|
|
|
|
if !repo.IsEmpty {
|
|
|
|
|
if err := gitrepo.SetDefaultBranch(ctx, ctx.Repo.Repository, *opts.DefaultBranch); err != nil {
|
|
|
|
|
if err := gitrepo.SetDefaultBranch(ctx, repo, repo.DefaultBranch); err != nil {
|
|
|
|
|
ctx.APIErrorInternal(err)
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
updateRepoLicense = true
|
|
|
|
|
}
|
|
|
|
|
repo.DefaultBranch = *opts.DefaultBranch
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if err := repo_service.UpdateRepository(ctx, repo, visibilityChanged); err != nil {
|
|
|
|
|
|