diff options
author | a1012112796 <1012112796@qq.com> | 2022-06-18 05:52:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-17 22:52:47 +0100 |
commit | 4b7f0c6c388ee71ede7eb3fa7ffe14d77bcbdab9 (patch) | |
tree | 62f14ec01b377e6a09cb9e595e0c018051d90060 /routers/web | |
parent | ae91913132fe2cf0db03b9d3012b7f663375ee5b (diff) | |
download | gitea-4b7f0c6c388ee71ede7eb3fa7ffe14d77bcbdab9.tar.gz gitea-4b7f0c6c388ee71ede7eb3fa7ffe14d77bcbdab9.zip |
fix permission check for delete tag (#19985) (#20001)
fix #19970
by the way, fix some error response about protected tags.
Signed-off-by: a1012112796 <1012112796@qq.com>
Diffstat (limited to 'routers/web')
-rw-r--r-- | routers/web/repo/branch.go | 6 | ||||
-rw-r--r-- | routers/web/repo/release.go | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go index 29b8acd61c..806814efde 100644 --- a/routers/web/repo/branch.go +++ b/routers/web/repo/branch.go @@ -370,6 +370,12 @@ func CreateBranch(ctx *context.Context) { err = repo_service.CreateNewBranchFromCommit(ctx.User, ctx.Repo.Repository, ctx.Repo.CommitID, form.NewBranchName) } if err != nil { + if models.IsErrProtectedTagName(err) { + ctx.Flash.Error(ctx.Tr("repo.release.tag_name_protected")) + ctx.Redirect(ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchNameSubURL()) + return + } + if models.IsErrTagAlreadyExists(err) { e := err.(models.ErrTagAlreadyExists) ctx.Flash.Error(ctx.Tr("repo.branch.tag_collision", e.TagName)) diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index b8e0d58e80..8068802808 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -519,7 +519,11 @@ func DeleteTag(ctx *context.Context) { func deleteReleaseOrTag(ctx *context.Context, isDelTag bool) { if err := releaseservice.DeleteReleaseByID(ctx.FormInt64("id"), ctx.User, isDelTag); err != nil { - ctx.Flash.Error("DeleteReleaseByID: " + err.Error()) + if models.IsErrProtectedTagName(err) { + ctx.Flash.Error(ctx.Tr("repo.release.tag_name_protected")) + } else { + ctx.Flash.Error("DeleteReleaseByID: " + err.Error()) + } } else { if isDelTag { ctx.Flash.Success(ctx.Tr("repo.release.deletion_tag_success")) |