From 0e18a26c568ac39b9cb4c06c96f31212626e6301 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 19 Aug 2024 11:42:37 -0700 Subject: [PATCH 1/4] Use a common message template instead of a special one --- options/locale/locale_en-US.ini | 2 +- routers/web/repo/commit.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 042fd549a0b30..1b5f52576d147 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -159,6 +159,7 @@ filter.public = Public filter.private = Private no_results_found = No results found. +load_failed = Load %s failed because of internal error [search] search = Search... @@ -1274,7 +1275,6 @@ commit_graph.color = Color commit.contained_in = This commit is contained in: commit.contained_in_default_branch = This commit is part of the default branch commit.load_referencing_branches_and_tags = Load branches and tags referencing this commit -commit.load_tags_failed = Load tags failed because of internal error blame = Blame download_file = Download file normal_view = Normal View diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index c91d5fad0565e..bbdf4962b008b 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -90,7 +90,7 @@ func Commits(ctx *context.Context) { commitsTagsMap, err := repo_model.FindTagsByCommitIDs(ctx, ctx.Repo.Repository.ID, commitIDs...) if err != nil { log.Error("FindTagsByCommitIDs: %v", err) - ctx.Flash.Error(ctx.Tr("repo.commit.load_tags_failed")) + ctx.Flash.Error(ctx.Tr("load_failed", "tags")) } else { ctx.Data["CommitsTagsMap"] = commitsTagsMap } From 6dfaa720dbb38db88f3a29e49781157266da9258 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 19 Aug 2024 20:28:08 -0700 Subject: [PATCH 2/4] Follow @wxiaoguang's suggestion --- options/locale/locale_en-US.ini | 2 +- routers/web/repo/commit.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 1b5f52576d147..06445a7b6ebcc 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -159,7 +159,7 @@ filter.public = Public filter.private = Private no_results_found = No results found. -load_failed = Load %s failed because of internal error +internal_error_skipped = Internal error occurred but is skipped: %s [search] search = Search... diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index bbdf4962b008b..a433dd228e3eb 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -90,7 +90,7 @@ func Commits(ctx *context.Context) { commitsTagsMap, err := repo_model.FindTagsByCommitIDs(ctx, ctx.Repo.Repository.ID, commitIDs...) if err != nil { log.Error("FindTagsByCommitIDs: %v", err) - ctx.Flash.Error(ctx.Tr("load_failed", "tags")) + ctx.Flash.Error(ctx.Tr("internal_error_skipped", "FindTagsByCommitIDs")) } else { ctx.Data["CommitsTagsMap"] = commitsTagsMap } From a1091923ecd72788774ad76aa234ea30a2050d83 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 12 Sep 2024 21:42:09 -0700 Subject: [PATCH 3/4] Only show function name for admin --- routers/web/repo/commit.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index a433dd228e3eb..73b496a31992c 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -90,7 +90,11 @@ func Commits(ctx *context.Context) { commitsTagsMap, err := repo_model.FindTagsByCommitIDs(ctx, ctx.Repo.Repository.ID, commitIDs...) if err != nil { log.Error("FindTagsByCommitIDs: %v", err) - ctx.Flash.Error(ctx.Tr("internal_error_skipped", "FindTagsByCommitIDs")) + if ctx.IsSigned && ctx.Doer.IsAdmin { + ctx.Flash.Error(ctx.Tr("internal_error_skipped", "FindTagsByCommitIDs")) + } else { + ctx.Flash.Error(ctx.Tr("internal_error_skipped", "Load Tags")) + } } else { ctx.Data["CommitsTagsMap"] = commitsTagsMap } From cac69d3a6a2a4b526cee51da03f136e13108ff93 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Fri, 13 Sep 2024 15:47:32 -0700 Subject: [PATCH 4/4] Revert "Only show function name for admin" This reverts commit a1091923ecd72788774ad76aa234ea30a2050d83. --- routers/web/repo/commit.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index 73b496a31992c..a433dd228e3eb 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -90,11 +90,7 @@ func Commits(ctx *context.Context) { commitsTagsMap, err := repo_model.FindTagsByCommitIDs(ctx, ctx.Repo.Repository.ID, commitIDs...) if err != nil { log.Error("FindTagsByCommitIDs: %v", err) - if ctx.IsSigned && ctx.Doer.IsAdmin { - ctx.Flash.Error(ctx.Tr("internal_error_skipped", "FindTagsByCommitIDs")) - } else { - ctx.Flash.Error(ctx.Tr("internal_error_skipped", "Load Tags")) - } + ctx.Flash.Error(ctx.Tr("internal_error_skipped", "FindTagsByCommitIDs")) } else { ctx.Data["CommitsTagsMap"] = commitsTagsMap }