Files
MokoGitea/services/pull/protected_branch.go
Jonathan Miller c572fcfe04
PR RC Release / Build RC Release (pull_request) Failing after 0s
Branch Policy Check / Verify merge target (pull_request) Failing after 0s
chore(core): rename Go module from code.gitea.io/gitea to MokoGitea namespace
Rename the Go module path from code.gitea.io/gitea to
git.mokoconsulting.tech/MokoConsulting/MokoGitea across the entire
codebase.

Scope:
- go.mod module declaration
- 2,235 Go source files (import paths)
- Dockerfile WORKDIR and COPY paths
- Swagger API templates
- golangci.yml linter config

External dependencies (code.gitea.io/gitea-vet, code.gitea.io/sdk/gitea,
gitea.com/gitea/act, etc.) are intentionally NOT renamed — they are
separate upstream modules.

Closes #132

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-25 00:22:38 -05:00

48 lines
1.3 KiB
Go

// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package pull
import (
"context"
git_model "git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/git"
repo_model "git.mokoconsulting.tech/MokoConsulting/MokoGitea/models/repo"
)
func CreateOrUpdateProtectedBranch(ctx context.Context, repo *repo_model.Repository,
protectBranch *git_model.ProtectedBranch, whitelistOptions git_model.WhitelistOptions,
) error {
err := git_model.UpdateProtectBranch(ctx, repo, protectBranch, whitelistOptions)
if err != nil {
return err
}
isPlainRule := !git_model.IsRuleNameSpecial(protectBranch.RuleName)
var isBranchExist bool
if isPlainRule {
isBranchExist, _ = git_model.IsBranchExist(ctx, repo.ID, protectBranch.RuleName)
}
if isBranchExist {
if err := CheckPRsForBaseBranch(ctx, repo, protectBranch.RuleName); err != nil {
return err
}
} else {
if !isPlainRule {
// FIXME: since we only need to recheck files protected rules, we could improve this
matchedBranches, err := git_model.FindAllMatchedBranches(ctx, repo.ID, protectBranch.RuleName)
if err != nil {
return err
}
for _, branchName := range matchedBranches {
if err = CheckPRsForBaseBranch(ctx, repo, branchName); err != nil {
return err
}
}
}
}
return nil
}