diff --git a/routers/web/repo/setting/default_branch.go b/routers/web/repo/setting/default_branch.go index 9eb8a26c0b..11c43aa69a 100644 --- a/routers/web/repo/setting/default_branch.go +++ b/routers/web/repo/setting/default_branch.go @@ -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) diff --git a/services/repository/branch.go b/services/repository/branch.go index 6ddc6badfa..0f15506691 100644 --- a/services/repository/branch.go +++ b/services/repository/branch.go @@ -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