aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authormzroot <minoga_dot@mail.ru>2024-06-14 19:56:10 +0300
committerGitHub <noreply@github.com>2024-06-14 18:56:10 +0200
commitd4e4226c3cbfa62a6adf15f4466747468eb208c7 (patch)
treed98ea2048ea29a43ef9dcf67a7b57655a6fcd369 /models
parent4e7b067a7fdfb3e2c8dfdf87475e3938051fd400 (diff)
downloadgitea-d4e4226c3cbfa62a6adf15f4466747468eb208c7.tar.gz
gitea-d4e4226c3cbfa62a6adf15f4466747468eb208c7.zip
Add tag protection via rest api #17862 (#31295)
Add tag protection manage via rest API. --------- Co-authored-by: Alexander Kogay <kogay.a@citilink.ru> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'models')
-rw-r--r--models/git/protected_tag.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/models/git/protected_tag.go b/models/git/protected_tag.go
index 8a05045651..9a6646c742 100644
--- a/models/git/protected_tag.go
+++ b/models/git/protected_tag.go
@@ -110,6 +110,19 @@ func GetProtectedTagByID(ctx context.Context, id int64) (*ProtectedTag, error) {
return tag, nil
}
+// GetProtectedTagByNamePattern gets protected tag by name_pattern
+func GetProtectedTagByNamePattern(ctx context.Context, repoID int64, pattern string) (*ProtectedTag, error) {
+ tag := &ProtectedTag{NamePattern: pattern, RepoID: repoID}
+ has, err := db.GetEngine(ctx).Get(tag)
+ if err != nil {
+ return nil, err
+ }
+ if !has {
+ return nil, nil
+ }
+ return tag, nil
+}
+
// IsUserAllowedToControlTag checks if a user can control the specific tag.
// It returns true if the tag name is not protected or the user is allowed to control it.
func IsUserAllowedToControlTag(ctx context.Context, tags []*ProtectedTag, tagName string, userID int64) (bool, error) {