[ACTIONS] port scheduled actions from Gitea

Refs: https://codeberg.org/forgejo/forgejo/issues/2798
This commit is contained in:
Earl Warren 2024-03-25 16:54:38 +01:00
parent 52e9d2db06
commit a117dfd2b1
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
3 changed files with 6 additions and 7 deletions

View file

@ -6,12 +6,11 @@ package setting
import ( import (
"net/http" "net/http"
repo_model "code.gitea.io/gitea/models/repo" git_model "code.gitea.io/gitea/models/git"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/gitrepo"
"code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers/web/repo" "code.gitea.io/gitea/routers/web/repo"
"code.gitea.io/gitea/services/context"
repo_service "code.gitea.io/gitea/services/repository" repo_service "code.gitea.io/gitea/services/repository"
) )
@ -37,7 +36,7 @@ func SetDefaultBranchPost(ctx *context.Context) {
branch := ctx.FormString("branch") 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, branch); err != nil {
switch { switch {
case ctx.Repo.GitRepo.IsErrBranchNotExist(err): case git_model.IsErrBranchNotExist(err):
ctx.Status(http.StatusNotFound) ctx.Status(http.StatusNotFound)
default: default:
ctx.ServerError("SetDefaultBranch", err) ctx.ServerError("SetDefaultBranch", err)

View file

@ -381,7 +381,7 @@ func RenameBranch(ctx context.Context, repo *repo_model.Repository, doer *user_m
log.Error("CancelPreviousJobs: %v", err) log.Error("CancelPreviousJobs: %v", err)
} }
err2 = gitRepo.SetDefaultBranch(ctx, repo, to) err2 = gitrepo.SetDefaultBranch(ctx, repo, to)
if err2 != nil { if err2 != nil {
return err2 return err2
} }
@ -546,7 +546,7 @@ func SetRepoDefaultBranch(ctx context.Context, repo *repo_model.Repository, gitR
log.Error("CancelPreviousJobs: %v", err) 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) { if !git.IsErrUnsupportedVersion(err) {
return err return err
} }

View file

@ -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) assert.NoError(t, err)
} }