From a117dfd2b1e37b36eb29b7d9cf1f59581697fd6b Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Mon, 25 Mar 2024 16:54:38 +0100 Subject: [PATCH] [ACTIONS] port scheduled actions from Gitea Refs: https://codeberg.org/forgejo/forgejo/issues/2798 --- routers/web/repo/setting/default_branch.go | 7 +++---- services/repository/branch.go | 4 ++-- tests/integration/integration_test.go | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/routers/web/repo/setting/default_branch.go b/routers/web/repo/setting/default_branch.go index 12e1ab7d1..881d148af 100644 --- a/routers/web/repo/setting/default_branch.go +++ b/routers/web/repo/setting/default_branch.go @@ -6,12 +6,11 @@ package setting import ( "net/http" - repo_model "code.gitea.io/gitea/models/repo" - "code.gitea.io/gitea/modules/git" - "code.gitea.io/gitea/modules/gitrepo" + git_model "code.gitea.io/gitea/models/git" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/routers/web/repo" + "code.gitea.io/gitea/services/context" repo_service "code.gitea.io/gitea/services/repository" ) @@ -37,7 +36,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 { switch { - case ctx.Repo.GitRepo.IsErrBranchNotExist(err): + case git_model.IsErrBranchNotExist(err): ctx.Status(http.StatusNotFound) default: ctx.ServerError("SetDefaultBranch", err) diff --git a/services/repository/branch.go b/services/repository/branch.go index 02ae80992..9d7193410 100644 --- a/services/repository/branch.go +++ b/services/repository/branch.go @@ -381,7 +381,7 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_m log.Error("CancelPreviousJobs: %v", err) } - err2 = gitRepo.SetDefaultBranch(ctx, repo, to) + err2 = gitrepo.SetDefaultBranch(ctx, repo, to) if err2 != nil { return err2 } @@ -546,7 +546,7 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitR log.Error("CancelPreviousJobs: %v", err) } - if err := gitRepo.SetDefaultBranch(newBranchName); err != nil { + if err := gitrepo.SetDefaultBranch(ctx, repo, newBranchName); err != nil { if !git.IsErrUnsupportedVersion(err) { return err } diff --git a/tests/integration/integration_test.go b/tests/integration/integration_test.go index 76b36a734..e8f28105c 100644 --- a/tests/integration/integration_test.go +++ b/tests/integration/integration_test.go @@ -635,7 +635,7 @@ func CreateDeclarativeRepo(t *testing.T, owner *user_model.User, name string, en } } - err := repo_model.UpdateRepositoryUnits(db.DefaultContext, repo, units, disabledUnits) + err := repo_service.UpdateRepositoryUnits(db.DefaultContext, repo, units, disabledUnits) assert.NoError(t, err) }