diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-11-26 07:21:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-26 07:21:41 +0800 |
commit | dfd511faf35fef68557e53763f9b06e5a139565d (patch) | |
tree | 79deaf19cd581543d1ad282a3f8ea46c7f411d76 /services/release/release.go | |
parent | 41b2d0be931dcac7d372efb0f8207fcb8379fce1 (diff) | |
download | gitea-dfd511faf35fef68557e53763f9b06e5a139565d.tar.gz gitea-dfd511faf35fef68557e53763f9b06e5a139565d.zip |
Fix comment permissions (#28213) (#28217)
backport #28213
This PR will fix some missed checks for private repositories' data on
web routes and API routes.
Diffstat (limited to 'services/release/release.go')
-rw-r--r-- | services/release/release.go | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/services/release/release.go b/services/release/release.go index c1190305b6..08f99a98f9 100644 --- a/services/release/release.go +++ b/services/release/release.go @@ -291,17 +291,7 @@ func UpdateRelease(doer *user_model.User, gitRepo *git.Repository, rel *repo_mod } // 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 { @@ -334,19 +324,19 @@ func DeleteReleaseByID(ctx context.Context, id int64, doer *user_model.User, del }, repository.NewPushCommits()) notification.NotifyDeleteRef(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) } |