From f2bb2016e154d95aaab5c6598ef715e211b92c78 Mon Sep 17 00:00:00 2001 From: Ellen Emilia Anna Zscheile Date: Mon, 4 Aug 2025 00:30:11 +0200 Subject: [PATCH] fix(build): actually enforce masked prefixes verification in lint-locale-usage --- .../allowed-masked-usage.txt | 44 ++++++++++++++++++- build/lint-locale-usage/handle-go.go | 6 ++- build/lint-locale-usage/lint-locale-usage.go | 6 ++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/build/lint-locale-usage/allowed-masked-usage.txt b/build/lint-locale-usage/allowed-masked-usage.txt index 9cfac054a5..560e341129 100644 --- a/build/lint-locale-usage/allowed-masked-usage.txt +++ b/build/lint-locale-usage/allowed-masked-usage.txt @@ -13,6 +13,18 @@ gpg.error.failed_retrieval_gpg_keys gpg.error.generate_hash gpg.error.no_committer_account +# models/actions/runner.go +actions.runners.status. + +# models/actions/status.go, templates/repo/actions/status.tmpl +actions.status. + +# models/git/commit_status.go +repo.commitstatus. + +# models/issues/comment.go +repo.issues.role. + # models/system/notice.go: func (n *Notice) TrStr() string admin.notices.type_1 admin.notices.type_2 @@ -20,7 +32,20 @@ admin.notices.type_2 # modules/setting/ui.go themes.names. +# modules/translation/translation.go +munits.data. + +# modules/web/middleware/binding.go +form. + +# routers/web/admin/admin.go +admin.dashboard. + +# routers/web/repo/activity.go +repo.activity.period. + # routers/web/repo/helper.go: "repo.tree_path_not_found_"+refType +repo. repo.tree_path_not_found_branch repo.tree_path_not_found_commit repo.tree_path_not_found_tag @@ -28,6 +53,9 @@ repo.tree_path_not_found_tag # services/context/context.go relativetime. +# services/cron/setting.go, templates/admin/cron.tmpl +admin.dashboard. + # templates/mail/issue/default.tmpl: $.locale.Tr mail.issue.in_tree_path @@ -37,9 +65,12 @@ repo.permissions. # templates/package/metadata/arch.tmpl: $.locale.Tr packages.details.license -# templates/repo/editor/commit_form.tmpl: ctx.Locale.Tr (printf "repo.signing.wont_sign.%s" .CanCommitToBranch.WontSignReason) +# templates/repo/editor/commit_form.tmpl repo.signing.wont_sign. +# templates/repo/issue/filter_list.tmpl, tests/integration/repo_test.go +repo.issues.filter_sort. + # templates/repo/issue/view_content.tmpl: indirection via $closeTranslationKey repo.issues.close repo.pulls.close @@ -51,10 +82,21 @@ repo.issues.ref_pull_from repo.issues.ref_reopening_from # templates/repo/issue/view_content/comments.tmpl: ctx.Locale.Tr (printf "projects.type-%d.display_name" .OldProject.Type) +projects. projects.type-1.display_name projects.type-2.display_name projects.type-3.display_name +# templates/repo/settings/webhook/link_menu.tmpl, templates/webhook/new.tmpl: repo.settings.web_hook_name_ +# tests/integration/repo_archive_text_test.go +repo.settings. + +# templates/shared/search/combo_multi.tmpl +search. + +# templates/user/dashboard/issues.tmpl +repo.issues.filter_sort. + # modules/migration/messenger.go: invocations of Messenger # services/migrations/migrate.go: messenger(...) # *: repo.migrate.*.description (unknown where they come from) diff --git a/build/lint-locale-usage/handle-go.go b/build/lint-locale-usage/handle-go.go index af97acf1c9..1b6ccf9fd3 100644 --- a/build/lint-locale-usage/handle-go.go +++ b/build/lint-locale-usage/handle-go.go @@ -43,7 +43,11 @@ func (handler Handler) handleGoTrArgument(fset *token.FileSet, n ast.Expr) { arg, err := strconv.Unquote(argLit.Value) if err == nil { // found interesting strings - handler.OnMsgidPrefix(fset, argLit.ValuePos, arg) + prep, trunc := PrepareMsgidPrefix(arg) + if trunc { + handler.OnWarning(fset, argLit.ValuePos, fmt.Sprintf("needed to truncate message id prefix: %s", arg)) + } + handler.OnMsgidPrefix(fset, argLit.ValuePos, prep) } } } diff --git a/build/lint-locale-usage/lint-locale-usage.go b/build/lint-locale-usage/lint-locale-usage.go index dba03587a2..344b583bfa 100644 --- a/build/lint-locale-usage/lint-locale-usage.go +++ b/build/lint-locale-usage/lint-locale-usage.go @@ -273,8 +273,10 @@ func main() { handler := Handler{ OnMsgidPrefix: func(fset *token.FileSet, pos token.Pos, msgidPrefix string) { - // TODO: perhaps we should check if we have any strings with such a prefix, but that's slow... - allowedMaskedPrefixes.Insert(DecodeKeyForStm(msgidPrefix)) + if !allowedMaskedPrefixes.Matches(DecodeKeyForStm(msgidPrefix)) { + gotAnyMsgidError = true + fmt.Printf("%s:\tmissing msgid prefix: %s\n", fset.Position(pos).String(), msgidPrefix) + } }, OnMsgid: func(fset *token.FileSet, pos token.Pos, msgid string) { if !msgids.Contains(msgid) {