Skip to content

Commit d61ac5d

Browse files
committed
Rename functions and add some comments
1 parent 4db395f commit d61ac5d

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

routers/web/repo/branch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func Branches(ctx *context.Context) {
4747
ctx.Data["PageIsViewCode"] = true
4848
ctx.Data["PageIsBranches"] = true
4949

50-
if !shared.RenderRepoSubMenu(ctx) {
50+
if !shared.PrepareForRepoSubMenu(ctx) {
5151
return
5252
}
5353

routers/web/repo/commit.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func Commits(ctx *context.Context) {
6262
}
6363
ctx.Data["PageIsViewCode"] = true
6464

65-
if !shared.RenderRepoSubMenu(ctx) {
65+
if !shared.PrepareForRepoSubMenu(ctx) {
6666
return
6767
}
6868

@@ -201,7 +201,7 @@ func SearchCommits(ctx *context.Context) {
201201
ctx.Data["PageIsCommits"] = true
202202
ctx.Data["PageIsViewCode"] = true
203203

204-
if !shared.RenderRepoSubMenu(ctx) {
204+
if !shared.PrepareForRepoSubMenu(ctx) {
205205
return
206206
}
207207

@@ -233,7 +233,7 @@ func SearchCommits(ctx *context.Context) {
233233

234234
// FileHistory show a file's reversions
235235
func FileHistory(ctx *context.Context) {
236-
if !shared.RenderRepoSubMenu(ctx) {
236+
if !shared.PrepareForRepoSubMenu(ctx) {
237237
return
238238
}
239239

routers/web/repo/release.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,9 @@ func Releases(ctx *context.Context) {
157157
ctx.Data["CanCreateBranch"] = false
158158
ctx.Data["HideBranchesInDropdown"] = true
159159

160+
// repo/release_tag_header.tmpl will render sub menu depending on the different permission
160161
if !ctx.Repo.CanRead(unit.TypeReleases) && ctx.Repo.CanRead(unit.TypeCode) {
161-
if !shared.RenderRepoSubMenu(ctx) {
162+
if !shared.PrepareForRepoSubMenu(ctx) {
162163
return
163164
}
164165
}
@@ -214,8 +215,9 @@ func TagsList(ctx *context.Context) {
214215
ctx.Data["HideBranchesInDropdown"] = true
215216
ctx.Data["CanCreateRelease"] = ctx.Repo.CanWrite(unit.TypeReleases) && !ctx.Repo.Repository.IsArchived
216217

218+
// repo/release_tag_header.tmpl will render sub menu depending on the different permission
217219
if !ctx.Repo.CanRead(unit.TypeReleases) && ctx.Repo.CanRead(unit.TypeCode) {
218-
if !shared.RenderRepoSubMenu(ctx) {
220+
if !shared.PrepareForRepoSubMenu(ctx) {
219221
return
220222
}
221223
}

routers/web/repo/shared/sub_menu.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ import (
99
repo_service "code.gitea.io/gitea/services/repository"
1010
)
1111

12-
func RenderRepoSubMenu(ctx *context.Context) bool {
13-
return renderLicenses(ctx)
12+
// PrepareForRepoSubMenu will prepare all sub menus' data for some repositories pages
13+
// TODO: moving prepae commits count, branches count, tags count and repository size to this function
14+
func PrepareForRepoSubMenu(ctx *context.Context) bool {
15+
return prepareForLicenses(ctx)
1416
}
1517

16-
func renderLicenses(ctx *context.Context) bool {
18+
func prepareForLicenses(ctx *context.Context) bool {
1719
repoLicenses, err := repo_model.GetRepoLicenses(ctx, ctx.Repo.Repository)
1820
if err != nil {
1921
ctx.ServerError("GetRepoLicenses", err)

routers/web/repo/view.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ func renderHomeCode(ctx *context.Context) {
981981
return
982982
}
983983

984-
if !shared.RenderRepoSubMenu(ctx) {
984+
if !shared.PrepareForRepoSubMenu(ctx) {
985985
return
986986
}
987987

0 commit comments

Comments
 (0)