Rename the main module to gotea.dev and the binary to gotea, and update the application name and English locale. Keep the external gitea.dev/sdk and gitea.dev/actionslib module imports unchanged. Assisted-by: OpenCode:DeepSeek-V4.1-Flash
37 lines
898 B
Go
37 lines
898 B
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package git
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
module_git "gotea.dev/modules/git"
|
|
)
|
|
|
|
// IsRefProtected checks whether a branch or tag ref is protected.
|
|
func IsRefProtected(ctx context.Context, repoID int64, ref module_git.RefName) (bool, error) {
|
|
if ref.IsBranch() {
|
|
return IsBranchProtected(ctx, repoID, ref.ShortName())
|
|
}
|
|
if !ref.IsTag() {
|
|
return false, nil
|
|
}
|
|
|
|
protectedTags, err := GetProtectedTags(ctx, repoID)
|
|
if err != nil {
|
|
return false, fmt.Errorf("get protected tags: %w", err)
|
|
}
|
|
for _, protectedTag := range protectedTags {
|
|
if err := protectedTag.EnsureCompiledPattern(); err != nil {
|
|
return false, fmt.Errorf("compile protected tag pattern %q: %w", protectedTag.NamePattern, err)
|
|
}
|
|
if protectedTag.matchString(ref.ShortName()) {
|
|
return true, nil
|
|
}
|
|
}
|
|
|
|
return false, nil
|
|
}
|