update licenses info when update default branch

This commit is contained in:
yp05327 2023-05-31 06:21:38 +00:00
parent 63a6da8867
commit b9c2329e0e
2 changed files with 15 additions and 1 deletions

View File

@ -11,6 +11,7 @@ import (
gitea_context "code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/private"
repo_module "code.gitea.io/gitea/modules/repository"
)
// SetDefaultBranch updates the default branch
@ -35,5 +36,13 @@ func SetDefaultBranch(ctx *gitea_context.PrivateContext) {
})
return
}
if err := repo_module.UpdateRepoLicenses(ctx, ctx.Repo.Repository, ctx.Repo.GitRepo); err != nil {
ctx.JSON(http.StatusInternalServerError, private.Response{
Err: fmt.Sprintf("Unable to set default branch on repository: %s/%s Error: %v", ownerName, repoName, err),
})
return
}
ctx.PlainText(http.StatusOK, "success")
}

View File

@ -19,6 +19,7 @@ import (
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/services/forms"
@ -74,7 +75,11 @@ func SetDefaultBranchPost(ctx *context.Context) {
}
}
if err := repo_model.UpdateDefaultBranch(repo); err != nil {
ctx.ServerError("SetDefaultBranch", err)
ctx.ServerError("UpdateDefaultBranch", err)
return
}
if err := repo_module.UpdateRepoLicenses(ctx, repo, ctx.Repo.GitRepo); err != nil {
ctx.ServerError("UpdateRepoLicenses", err)
return
}
}