0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-19 02:00:58 +02:00

Merge 49ba333c05e1c62f4c68f79d95bc7f60b59f9844 into b46623f6a5aa8beb3613bd89abde8d77b1e66758

This commit is contained in:
Lunny Xiao 2025-07-11 03:33:39 +03:00 committed by GitHub
commit 6cdbd1f814
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -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 // Default branch only updated if changed and exist or the repository is empty
updateRepoLicense := false updateRepoLicense := false
if opts.DefaultBranch != nil && repo.DefaultBranch != *opts.DefaultBranch && (repo.IsEmpty || gitrepo.IsBranchExist(ctx, ctx.Repo.Repository, *opts.DefaultBranch)) { 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 !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) ctx.APIErrorInternal(err)
return err return err
} }
updateRepoLicense = true updateRepoLicense = true
} }
repo.DefaultBranch = *opts.DefaultBranch
} }
if err := repo_service.UpdateRepository(ctx, repo, visibilityChanged); err != nil { if err := repo_service.UpdateRepository(ctx, repo, visibilityChanged); err != nil {

View File

@ -43,7 +43,7 @@ func InitWiki(ctx context.Context, repo *repo_model.Repository) error {
return fmt.Errorf("InitRepository: %w", err) return fmt.Errorf("InitRepository: %w", err)
} else if err = gitrepo.CreateDelegateHooks(ctx, repo.WikiStorageRepo()); err != nil { } else if err = gitrepo.CreateDelegateHooks(ctx, repo.WikiStorageRepo()); err != nil {
return fmt.Errorf("createDelegateHooks: %w", err) return fmt.Errorf("createDelegateHooks: %w", err)
} else if _, _, err = git.NewCommand("symbolic-ref", "HEAD").AddDynamicArguments(git.BranchPrefix+repo.DefaultWikiBranch).RunStdString(ctx, &git.RunOpts{Dir: repo.WikiPath()}); err != nil { } else if err = gitrepo.SetDefaultBranch(ctx, repo.WikiStorageRepo(), repo.DefaultWikiBranch); err != nil {
return fmt.Errorf("unable to set default wiki branch to %q: %w", repo.DefaultWikiBranch, err) return fmt.Errorf("unable to set default wiki branch to %q: %w", repo.DefaultWikiBranch, err)
} }
return nil return nil