aboutsummaryrefslogtreecommitdiffstats
path: root/modules/context/repo.go
diff options
context:
space:
mode:
authorZettat123 <zettat123@gmail.com>2023-09-28 21:21:47 +0800
committerGitHub <noreply@github.com>2023-09-28 13:21:47 +0000
commit3fcad582c9b9bfe66f4a346652f82b1aaf18430d (patch)
tree05e37e3eeeab2823640bbcc86d2602700432dbca /modules/context/repo.go
parent1c039b4e1e57f31caea9c873e4f9c79300ddb344 (diff)
downloadgitea-3fcad582c9b9bfe66f4a346652f82b1aaf18430d.tar.gz
gitea-3fcad582c9b9bfe66f4a346652f82b1aaf18430d.zip
Improvements of releases list and tags list (#25859)
Follow #23465 and #25624 This PR introduces the following improvements: - We do not need to call `GetTags` to get tags because tags have been loaded by `RepoAssignment` https://github.com/go-gitea/gitea/blob/ef90fdbd1d7e1f62ed5bf18757e00e97817eb602/modules/context/repo.go#L663-L668 - Similarly, the number of tags and releases also have been loaded by `RepoAssignment`, so the related code has been removed from the handlers. The query condition of `GetReleaseCountByRepoID` in `RepoAssignment` has been changed to include draft releases. https://github.com/go-gitea/gitea/blob/ef90fdbd1d7e1f62ed5bf18757e00e97817eb602/modules/context/repo.go#L538-L551 - `releasesOrTags` function has been removed. The code for rendering releases list and tags list moved to `Releases` and `TagList` respectively.
Diffstat (limited to 'modules/context/repo.go')
-rw-r--r--modules/context/repo.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index 44ae624568..395ccf4b10 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -545,7 +545,10 @@ func RepoAssignment(ctx *Context) context.CancelFunc {
ctx.ServerError("GetReleaseCountByRepoID", err)
return nil
}
- ctx.Data["NumReleases"], err = repo_model.GetReleaseCountByRepoID(ctx, ctx.Repo.Repository.ID, repo_model.FindReleasesOptions{})
+ ctx.Data["NumReleases"], err = repo_model.GetReleaseCountByRepoID(ctx, ctx.Repo.Repository.ID, repo_model.FindReleasesOptions{
+ // only show draft releases for users who can write, read-only users shouldn't see draft releases.
+ IncludeDrafts: ctx.Repo.CanWrite(unit_model.TypeReleases),
+ })
if err != nil {
ctx.ServerError("GetReleaseCountByRepoID", err)
return nil