diff options
Diffstat (limited to 'services/release/release.go')
-rw-r--r-- | services/release/release.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/services/release/release.go b/services/release/release.go index a3d7d4720..6fa966de1 100644 --- a/services/release/release.go +++ b/services/release/release.go @@ -294,6 +294,20 @@ func DeleteReleaseByID(ctx context.Context, id int64, doer *user_model.User, del } if delTag { + protectedTags, err := git_model.GetProtectedTags(rel.RepoID) + if err != nil { + return fmt.Errorf("GetProtectedTags: %v", err) + } + isAllowed, err := git_model.IsUserAllowedToControlTag(protectedTags, rel.TagName, rel.PublisherID) + if err != nil { + return err + } + if !isAllowed { + return models.ErrProtectedTagName{ + TagName: rel.TagName, + } + } + if stdout, _, err := git.NewCommand(ctx, "tag", "-d", rel.TagName). SetDescription(fmt.Sprintf("DeleteReleaseByID (git tag -d): %d", rel.ID)). RunStdString(&git.RunOpts{Dir: repo.RepoPath()}); err != nil && !strings.Contains(err.Error(), "not found") { |