From b45f9073474da559895ea40487c82fd3155f955a Mon Sep 17 00:00:00 2001
From: yp05327 <576951401@qq.com>
Date: Fri, 24 Nov 2023 06:22:19 +0000
Subject: [PATCH] improve variable name
---
modules/context/repo.go | 2 +-
modules/repository/license.go | 4 ++--
routers/web/repo/branch.go | 4 ++--
routers/web/repo/commit.go | 12 ++++++------
routers/web/repo/view.go | 4 ++--
templates/repo/sub_menu.tmpl | 6 +++---
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/modules/context/repo.go b/modules/context/repo.go
index 25c9c82007..ee5edb4384 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -405,7 +405,7 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
ctx.ServerError("GetRepoLicenses", err)
return
}
- ctx.Data["Licenses"] = repoLicenses.StringList()
+ ctx.Data["DetectedRepoLicenses"] = repoLicenses.StringList()
}
// RepoIDAssignment returns a handler which assigns the repo to the context.
diff --git a/modules/repository/license.go b/modules/repository/license.go
index d049456bf8..a475e96cb6 100644
--- a/modules/repository/license.go
+++ b/modules/repository/license.go
@@ -222,8 +222,8 @@ func UpdateRepoLicenses(ctx context.Context, repo *repo_model.Repository, commit
return nil
}
-// GetLicenseFileName returns license file name in the repository if it exists
-func GetLicenseFileName(ctx context.Context, repo *repo_model.Repository, commit *git.Commit) (string, error) {
+// GetDetectedLicenseFileName returns license file name in the repository if it exists
+func GetDetectedLicenseFileName(ctx context.Context, repo *repo_model.Repository, commit *git.Commit) (string, error) {
if commit == nil {
return "", nil
}
diff --git a/routers/web/repo/branch.go b/routers/web/repo/branch.go
index 6aa5b210a1..8b59f6deae 100644
--- a/routers/web/repo/branch.go
+++ b/routers/web/repo/branch.go
@@ -84,9 +84,9 @@ func Branches(ctx *context.Context) {
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager
- ctx.Data["LicenseFileName"], err = repo_module.GetLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
+ ctx.Data["DetectedLicenseFileName"], err = repo_module.GetDetectedLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
if err != nil {
- ctx.ServerError("GetLicenseFileName", err)
+ ctx.ServerError("GetDetectedLicenseFileName", err)
return
}
ctx.HTML(http.StatusOK, tplBranch)
diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go
index ceda2a4a59..694a4caa95 100644
--- a/routers/web/repo/commit.go
+++ b/routers/web/repo/commit.go
@@ -86,9 +86,9 @@ func Commits(ctx *context.Context) {
pager := context.NewPagination(int(commitsCount), pageSize, page, 5)
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager
- ctx.Data["LicenseFileName"], err = repo_module.GetLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
+ ctx.Data["DetectedLicenseFileName"], err = repo_module.GetDetectedLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
if err != nil {
- ctx.ServerError("GetLicenseFileName", err)
+ ctx.ServerError("GetDetectedLicenseFileName", err)
return
}
ctx.HTML(http.StatusOK, tplCommits)
@@ -208,9 +208,9 @@ func SearchCommits(ctx *context.Context) {
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
ctx.Data["RefName"] = ctx.Repo.RefName
- ctx.Data["LicenseFileName"], err = repo_module.GetLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
+ ctx.Data["DetectedLicenseFileName"], err = repo_module.GetDetectedLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
if err != nil {
- ctx.ServerError("GetLicenseFileName", err)
+ ctx.ServerError("GetDetectedLicenseFileName", err)
return
}
ctx.HTML(http.StatusOK, tplCommits)
@@ -261,9 +261,9 @@ func FileHistory(ctx *context.Context) {
pager.SetDefaultParams(ctx)
ctx.Data["Page"] = pager
- ctx.Data["LicenseFileName"], err = repo_module.GetLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
+ ctx.Data["DetectedLicenseFileName"], err = repo_module.GetDetectedLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
if err != nil {
- ctx.ServerError("GetLicenseFileName", err)
+ ctx.ServerError("GetDetectedLicenseFileName", err)
return
}
ctx.HTML(http.StatusOK, tplCommits)
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index ff23debf7a..8325c06586 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -913,9 +913,9 @@ func renderCode(ctx *context.Context) {
ctx.Data["TreeLink"] = treeLink
ctx.Data["TreeNames"] = treeNames
ctx.Data["BranchLink"] = branchLink
- ctx.Data["LicenseFileName"], err = repo_module.GetLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
+ ctx.Data["DetectedLicenseFileName"], err = repo_module.GetDetectedLicenseFileName(ctx, ctx.Repo.Repository, ctx.Repo.Commit)
if err != nil {
- ctx.ServerError("GetLicenseFileName", err)
+ ctx.ServerError("GetDetectedLicenseFileName", err)
return
}
ctx.HTML(http.StatusOK, tplRepoHome)
diff --git a/templates/repo/sub_menu.tmpl b/templates/repo/sub_menu.tmpl
index b289c5c313..ea689f92ed 100644
--- a/templates/repo/sub_menu.tmpl
+++ b/templates/repo/sub_menu.tmpl
@@ -13,9 +13,9 @@
{{svg "octicon-tag"}} {{ctx.Locale.PrettyNumber .NumTags}} {{ctx.Locale.TrN .NumTags "repo.tag" "repo.tags"}}
{{end}}
- {{if .Licenses}}
-
- {{svg "octicon-law"}} {{if eq (len .Licenses) 1}}{{index .Licenses 0}}{{else}}{{.locale.Tr "repo.multiple_licenses"}}{{end}}
+ {{if .DetectedRepoLicenses}}
+
+ {{svg "octicon-law"}} {{if eq (len .DetectedRepoLicenses) 1}}{{index .DetectedRepoLicenses 0}}{{else}}{{.locale.Tr "repo.multiple_licenses"}}{{end}}
{{end}}