@@ -71,18 +71,6 @@ func calReleaseNumCommitsBehind(repoCtx *context.Repository, release *repo_model
71
71
func Releases (ctx * context.Context ) {
72
72
ctx .Data ["PageIsReleaseList" ] = true
73
73
ctx .Data ["Title" ] = ctx .Tr ("repo.release.releases" )
74
- releasesOrTags (ctx , false )
75
- }
76
-
77
- // TagsList render tags list page
78
- func TagsList (ctx * context.Context ) {
79
- ctx .Data ["PageIsTagList" ] = true
80
- ctx .Data ["Title" ] = ctx .Tr ("repo.release.tags" )
81
- releasesOrTags (ctx , true )
82
- }
83
-
84
- func releasesOrTags (ctx * context.Context , isTagList bool ) {
85
- ctx .Data ["DefaultBranch" ] = ctx .Repo .Repository .DefaultBranch
86
74
ctx .Data ["IsViewBranch" ] = false
87
75
ctx .Data ["IsViewTag" ] = true
88
76
// Disable the showCreateNewBranch form in the dropdown on this page.
@@ -100,35 +88,13 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
100
88
listOptions .PageSize = setting .API .MaxResponseItems
101
89
}
102
90
103
- // TODO(20073) tags are used for compare feature which needs all tags
104
- // filtering is done on the client-side atm
105
- tagListStart , tagListEnd := 0 , 0
106
- if isTagList {
107
- tagListStart , tagListEnd = listOptions .GetStartEnd ()
108
- }
109
-
110
- tags , err := ctx .Repo .GitRepo .GetTags (tagListStart , tagListEnd )
111
- if err != nil {
112
- ctx .ServerError ("GetTags" , err )
113
- return
114
- }
115
- ctx .Data ["Tags" ] = tags
116
-
117
91
writeAccess := ctx .Repo .CanWrite (unit .TypeReleases )
118
92
ctx .Data ["CanCreateRelease" ] = writeAccess && ! ctx .Repo .Repository .IsArchived
119
93
120
94
opts := repo_model.FindReleasesOptions {
121
95
ListOptions : listOptions ,
122
- }
123
- if isTagList {
124
- // for the tags list page, show all releases with real tags (having real commit-id),
125
- // the drafts should also be included because a real tag might be used as a draft.
126
- opts .IncludeDrafts = true
127
- opts .IncludeTags = true
128
- opts .HasSha1 = util .OptionalBoolTrue
129
- } else {
130
96
// only show draft releases for users who can write, read-only users shouldn't see draft releases.
131
- opts . IncludeDrafts = writeAccess
97
+ IncludeDrafts : writeAccess ,
132
98
}
133
99
134
100
releases , err := repo_model .GetReleasesByRepoID (ctx , ctx .Repo .Repository .ID , opts )
@@ -137,12 +103,6 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
137
103
return
138
104
}
139
105
140
- count , err := repo_model .GetReleaseCountByRepoID (ctx , ctx .Repo .Repository .ID , opts )
141
- if err != nil {
142
- ctx .ServerError ("GetReleaseCountByRepoID" , err )
143
- return
144
- }
145
-
146
106
for _ , release := range releases {
147
107
release .Repo = ctx .Repo .Repository
148
108
}
@@ -197,16 +157,59 @@ func releasesOrTags(ctx *context.Context, isTagList bool) {
197
157
198
158
ctx .Data ["Releases" ] = releases
199
159
200
- pager := context .NewPagination (int (count ), opts .PageSize , opts .Page , 5 )
160
+ numReleases := ctx .Data ["NumReleases" ].(int64 )
161
+ pager := context .NewPagination (int (numReleases ), opts .PageSize , opts .Page , 5 )
201
162
pager .SetDefaultParams (ctx )
202
163
ctx .Data ["Page" ] = pager
203
164
204
- if isTagList {
205
- ctx .Data ["PageIsViewCode" ] = ! ctx .Repo .Repository .UnitEnabled (ctx , unit .TypeReleases )
206
- ctx .HTML (http .StatusOK , tplTagsList )
207
- } else {
208
- ctx .HTML (http .StatusOK , tplReleasesList )
165
+ ctx .HTML (http .StatusOK , tplReleasesList )
166
+ }
167
+
168
+ // TagsList render tags list page
169
+ func TagsList (ctx * context.Context ) {
170
+ ctx .Data ["PageIsTagList" ] = true
171
+ ctx .Data ["Title" ] = ctx .Tr ("repo.release.tags" )
172
+ ctx .Data ["IsViewBranch" ] = false
173
+ ctx .Data ["IsViewTag" ] = true
174
+ // Disable the showCreateNewBranch form in the dropdown on this page.
175
+ ctx .Data ["CanCreateBranch" ] = false
176
+ ctx .Data ["HideBranchesInDropdown" ] = true
177
+
178
+ listOptions := db.ListOptions {
179
+ Page : ctx .FormInt ("page" ),
180
+ PageSize : ctx .FormInt ("limit" ),
181
+ }
182
+ if listOptions .PageSize == 0 {
183
+ listOptions .PageSize = setting .Repository .Release .DefaultPagingNum
184
+ }
185
+ if listOptions .PageSize > setting .API .MaxResponseItems {
186
+ listOptions .PageSize = setting .API .MaxResponseItems
187
+ }
188
+
189
+ opts := repo_model.FindReleasesOptions {
190
+ ListOptions : listOptions ,
191
+ // for the tags list page, show all releases with real tags (having real commit-id),
192
+ // the drafts should also be included because a real tag might be used as a draft.
193
+ IncludeDrafts : true ,
194
+ IncludeTags : true ,
195
+ HasSha1 : util .OptionalBoolTrue ,
196
+ }
197
+
198
+ releases , err := repo_model .GetReleasesByRepoID (ctx , ctx .Repo .Repository .ID , opts )
199
+ if err != nil {
200
+ ctx .ServerError ("GetReleasesByRepoID" , err )
201
+ return
209
202
}
203
+
204
+ ctx .Data ["Releases" ] = releases
205
+
206
+ numTags := ctx .Data ["NumTags" ].(int64 )
207
+ pager := context .NewPagination (int (numTags ), opts .PageSize , opts .Page , 5 )
208
+ pager .SetDefaultParams (ctx )
209
+ ctx .Data ["Page" ] = pager
210
+
211
+ ctx .Data ["PageIsViewCode" ] = ! ctx .Repo .Repository .UnitEnabled (ctx , unit .TypeReleases )
212
+ ctx .HTML (http .StatusOK , tplTagsList )
210
213
}
211
214
212
215
// ReleasesFeedRSS get feeds for releases in RSS format
0 commit comments