FEATURE: Remove unnecessary org names from PR oneboxes (#31102)

Instead of displaying:

`discourse:main <- discourse:feature` or `discourse:main <-
user:feature`

shows:

`main <- feature` or `main <- user:feature`
This commit is contained in:
Jarek Radosz
2025-02-01 01:05:08 +01:00
committed by GitHub
parent 9f41ce7fce
commit 3a93a61092
3 changed files with 14 additions and 5 deletions

View File

@@ -36,7 +36,8 @@ module Onebox
result["created_at_time"] = created_at.strftime("%T")
ulink = URI(link)
result["domain"] = "#{ulink.host}/#{ulink.path.split("/")[1]}/#{ulink.path.split("/")[2]}"
_, org, repo = ulink.path.split("/")
result["domain"] = "#{ulink.host}/#{org}/#{repo}"
result["body"], result["excerpt"] = compute_body(result["body"])
@@ -50,6 +51,7 @@ module Onebox
else
result["pr"] = true
end
result["i18n"] = i18n
result["i18n"]["pr_summary"] = I18n.t(
"onebox.github.pr_summary",
@@ -62,6 +64,9 @@ module Onebox
)
result["is_private"] = result.dig("base", "repo", "private")
result["base"]["label"].sub!(/\A#{org}:/, "")
result["head"]["label"].sub!(/\A#{org}:/, "")
result
end