Skip to content

Commit 51f4ad8

Browse files
committed
Only display license on repository home page
1 parent 3623a5c commit 51f4ad8

File tree

5 files changed

+3
-41
lines changed

5 files changed

+3
-41
lines changed

routers/web/repo/branch.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"code.gitea.io/gitea/modules/util"
2525
"code.gitea.io/gitea/modules/web"
2626
"code.gitea.io/gitea/routers/utils"
27-
"code.gitea.io/gitea/routers/web/repo/shared"
2827
"code.gitea.io/gitea/services/context"
2928
"code.gitea.io/gitea/services/forms"
3029
release_service "code.gitea.io/gitea/services/release"
@@ -47,10 +46,6 @@ func Branches(ctx *context.Context) {
4746
ctx.Data["PageIsViewCode"] = true
4847
ctx.Data["PageIsBranches"] = true
4948

50-
if !shared.PrepareForRepoSubMenu(ctx) {
51-
return
52-
}
53-
5449
page := ctx.FormInt("page")
5550
if page <= 1 {
5651
page = 1

routers/web/repo/commit.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"code.gitea.io/gitea/modules/markup"
2929
"code.gitea.io/gitea/modules/setting"
3030
"code.gitea.io/gitea/modules/util"
31-
"code.gitea.io/gitea/routers/web/repo/shared"
3231
"code.gitea.io/gitea/services/context"
3332
"code.gitea.io/gitea/services/gitdiff"
3433
repo_service "code.gitea.io/gitea/services/repository"
@@ -62,10 +61,6 @@ func Commits(ctx *context.Context) {
6261
}
6362
ctx.Data["PageIsViewCode"] = true
6463

65-
if !shared.PrepareForRepoSubMenu(ctx) {
66-
return
67-
}
68-
6964
commitsCount, err := ctx.Repo.GetCommitsCount()
7065
if err != nil {
7166
ctx.ServerError("GetCommitsCount", err)
@@ -201,10 +196,6 @@ func SearchCommits(ctx *context.Context) {
201196
ctx.Data["PageIsCommits"] = true
202197
ctx.Data["PageIsViewCode"] = true
203198

204-
if !shared.PrepareForRepoSubMenu(ctx) {
205-
return
206-
}
207-
208199
query := ctx.FormTrim("q")
209200
if len(query) == 0 {
210201
ctx.Redirect(ctx.Repo.RepoLink + "/commits/" + ctx.Repo.BranchNameSubURL())
@@ -233,10 +224,6 @@ func SearchCommits(ctx *context.Context) {
233224

234225
// FileHistory show a file's reversions
235226
func FileHistory(ctx *context.Context) {
236-
if !shared.PrepareForRepoSubMenu(ctx) {
237-
return
238-
}
239-
240227
fileName := ctx.Repo.TreePath
241228
if len(fileName) == 0 {
242229
Commits(ctx)

routers/web/repo/release.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"code.gitea.io/gitea/modules/util"
2727
"code.gitea.io/gitea/modules/web"
2828
"code.gitea.io/gitea/routers/web/feed"
29-
"code.gitea.io/gitea/routers/web/repo/shared"
3029
shared_user "code.gitea.io/gitea/routers/web/shared/user"
3130
"code.gitea.io/gitea/services/context"
3231
"code.gitea.io/gitea/services/context/upload"
@@ -157,13 +156,6 @@ func Releases(ctx *context.Context) {
157156
ctx.Data["CanCreateBranch"] = false
158157
ctx.Data["HideBranchesInDropdown"] = true
159158

160-
// repo/release_tag_header.tmpl will render sub menu depending on the different permission
161-
if !ctx.Repo.CanRead(unit.TypeReleases) && ctx.Repo.CanRead(unit.TypeCode) {
162-
if !shared.PrepareForRepoSubMenu(ctx) {
163-
return
164-
}
165-
}
166-
167159
listOptions := db.ListOptions{
168160
Page: ctx.FormInt("page"),
169161
PageSize: ctx.FormInt("limit"),
@@ -215,13 +207,6 @@ func TagsList(ctx *context.Context) {
215207
ctx.Data["HideBranchesInDropdown"] = true
216208
ctx.Data["CanCreateRelease"] = ctx.Repo.CanWrite(unit.TypeReleases) && !ctx.Repo.Repository.IsArchived
217209

218-
// repo/release_tag_header.tmpl will render sub menu depending on the different permission
219-
if !ctx.Repo.CanRead(unit.TypeReleases) && ctx.Repo.CanRead(unit.TypeCode) {
220-
if !shared.PrepareForRepoSubMenu(ctx) {
221-
return
222-
}
223-
}
224-
225210
namePattern := ctx.FormTrim("q")
226211

227212
listOptions := db.ListOptions{

routers/web/repo/shared/sub_menu.go renamed to routers/web/repo/shared/license.go

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

12-
// PrepareForRepoSubMenu will prepare all sub menus' data for some repositories pages
13-
// TODO: moving preparation for commits count, branches count, tags count and repository size to this function
14-
func PrepareForRepoSubMenu(ctx *context.Context) bool {
15-
return prepareForLicenses(ctx)
16-
}
17-
18-
func prepareForLicenses(ctx *context.Context) bool {
12+
func PrepareForLicenses(ctx *context.Context) bool {
1913
repoLicenses, err := repo_model.GetRepoLicenses(ctx, ctx.Repo.Repository)
2014
if err != nil {
2115
ctx.ServerError("GetRepoLicenses", err)

routers/web/repo/view.go

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

984-
if !shared.PrepareForRepoSubMenu(ctx) {
984+
// only show licenses on repository's home page
985+
if !shared.PrepareForLicenses(ctx) {
985986
return
986987
}
987988

0 commit comments

Comments
 (0)