fix changes from 28691

This commit is contained in:
yp05327 2024-01-17 04:47:56 +00:00
parent 91c54540e5
commit 5e72897db8
2 changed files with 5 additions and 3 deletions

View File

@ -9,7 +9,6 @@ import (
git_model "code.gitea.io/gitea/models/git"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/log"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers/web/repo"
repo_service "code.gitea.io/gitea/services/repository"
@ -35,7 +34,7 @@ func SetDefaultBranchPost(ctx *context.Context) {
}
branch := ctx.FormString("branch")
if err := repo_service.SetRepoDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, branch); err != nil {
if err := repo_service.SetRepoDefaultBranch(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.Repo.Commit, branch); err != nil {
switch {
case git_model.IsErrBranchNotExist(err):
ctx.Status(http.StatusNotFound)

View File

@ -468,7 +468,7 @@ func AddAllRepoBranchesToSyncQueue(ctx context.Context, doerID int64) error {
return nil
}
func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, newBranchName string) error {
func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitRepo *git.Repository, commit *git.Commit, newBranchName string) error {
if repo.DefaultBranch == newBranchName {
return nil
}
@ -505,6 +505,9 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitR
return err
}
}
if err := repo_module.UpdateRepoLicenses(ctx, repo, commit); err != nil {
log.Error("UpdateRepoLicenses: %v", err)
}
return nil
}); err != nil {
return err