mirror of
https://github.com/discourse/discourse.git
synced 2025-02-24 06:27:24 +08:00
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:
parent
9f41ce7fce
commit
3a93a61092
@ -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
|
||||
|
||||
|
@ -63,8 +63,8 @@
|
||||
"repo": null
|
||||
},
|
||||
"base": {
|
||||
"label": "discourse:master",
|
||||
"ref": "master",
|
||||
"label": "discourse:main",
|
||||
"ref": "main",
|
||||
"sha": "cc79d22f82ede170dd86a05274eb3c2c5eb02912",
|
||||
"user": {
|
||||
"login": "discourse",
|
||||
@ -165,8 +165,8 @@
|
||||
"forks": 1876,
|
||||
"open_issues": 38,
|
||||
"watchers": 7857,
|
||||
"master_branch": "master",
|
||||
"default_branch": "master"
|
||||
"main_branch": "main",
|
||||
"default_branch": "main"
|
||||
}
|
||||
},
|
||||
"_links": {
|
||||
|
@ -21,6 +21,10 @@ RSpec.describe Onebox::Engine::GithubPullRequestOnebox do
|
||||
expect(html).to include("discourse")
|
||||
end
|
||||
|
||||
it "includes branch names" do
|
||||
expect(html).to include("<code>main</code> ← <code>jamesaanderson:add-audio-onebox</code>")
|
||||
end
|
||||
|
||||
it "includes commit author gravatar" do
|
||||
expect(html).to include("b3e9977094ce189bbb493cf7f9adea21")
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user