diff options
author | a1012112796 <1012112796@qq.com> | 2022-06-17 04:03:03 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-16 22:03:03 +0200 |
commit | e3e06d13afdd882ca5934fde77217ff9554354c4 (patch) | |
tree | 5f46b0277127af587f1aed139d15b024f9dae74d /services/release/release.go | |
parent | 89b0aac37449cf7ccdfa52c6edbe537257228bc1 (diff) | |
download | gitea-e3e06d13afdd882ca5934fde77217ff9554354c4.tar.gz gitea-e3e06d13afdd882ca5934fde77217ff9554354c4.zip |
fix permission check for delete tag (#19985)
fix #19970
by the way, fix some error response about protected tags.
Signed-off-by: a1012112796 <1012112796@qq.com>
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 a3d7d47201..6fa966de1f 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") { |