summaryrefslogtreecommitdiffstats
path: root/services/release
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2023-11-26 01:21:21 +0800
committerGitHub <noreply@github.com>2023-11-25 17:21:21 +0000
commit882e5023270ed844a4b2911e555e82fe905869e4 (patch)
tree4d0d28ccf485e123ea7cbe719e7a414065ffba17 /services/release
parent80217cacfc3fcf0ffa0dc203843c11e318f85d19 (diff)
downloadgitea-882e5023270ed844a4b2911e555e82fe905869e4.tar.gz
gitea-882e5023270ed844a4b2911e555e82fe905869e4.zip
Fix comment permissions (#28213)
This PR will fix some missed checks for private repositories' data on web routes and API routes.
Diffstat (limited to 'services/release')
-rw-r--r--services/release/release.go18
1 files changed, 4 insertions, 14 deletions
diff --git a/services/release/release.go b/services/release/release.go
index e0035d42fc..3ba2a3f611 100644
--- a/services/release/release.go
+++ b/services/release/release.go
@@ -301,17 +301,7 @@ func UpdateRelease(ctx context.Context, doer *user_model.User, gitRepo *git.Repo
}
// DeleteReleaseByID deletes a release and corresponding Git tag by given ID.
-func DeleteReleaseByID(ctx context.Context, id int64, doer *user_model.User, delTag bool) error {
- rel, err := repo_model.GetReleaseByID(ctx, id)
- if err != nil {
- return fmt.Errorf("GetReleaseByID: %w", err)
- }
-
- repo, err := repo_model.GetRepositoryByID(ctx, rel.RepoID)
- if err != nil {
- return fmt.Errorf("GetRepositoryByID: %w", err)
- }
-
+func DeleteReleaseByID(ctx context.Context, repo *repo_model.Repository, rel *repo_model.Release, doer *user_model.User, delTag bool) error {
if delTag {
protectedTags, err := git_model.GetProtectedTags(ctx, rel.RepoID)
if err != nil {
@@ -344,19 +334,19 @@ func DeleteReleaseByID(ctx context.Context, id int64, doer *user_model.User, del
}, repository.NewPushCommits())
notify_service.DeleteRef(ctx, doer, repo, refName)
- if err := repo_model.DeleteReleaseByID(ctx, id); err != nil {
+ if err := repo_model.DeleteReleaseByID(ctx, rel.ID); err != nil {
return fmt.Errorf("DeleteReleaseByID: %w", err)
}
} else {
rel.IsTag = true
- if err = repo_model.UpdateRelease(ctx, rel); err != nil {
+ if err := repo_model.UpdateRelease(ctx, rel); err != nil {
return fmt.Errorf("Update: %w", err)
}
}
rel.Repo = repo
- if err = rel.LoadAttributes(ctx); err != nil {
+ if err := rel.LoadAttributes(ctx); err != nil {
return fmt.Errorf("LoadAttributes: %w", err)
}