A platform for community discussion. Free, open, simple.
FEATURE: Remove unnecessary org names from PR oneboxes (#31102)
Jarek Radosz3a93a61092ce
diff --git a/lib/onebox/engine/github_pull_request_onebox.rb b/lib/onebox/engine/github_pull_request_onebox.rbindex 5ade5ed018c..64bbac614a8 100644--- a/lib/onebox/engine/github_pull_request_onebox.rb+++ b/lib/onebox/engine/github_pull_request_onebox.rb@@ -36,7 +36,8 @@ module Oneboxresult["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 Oneboxelseresult["pr"] = trueend+result["i18n"] = i18nresult["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}:/, "")+resultenddiff --git a/spec/fixtures/onebox/githubpullrequest.response b/spec/fixtures/onebox/githubpullrequest.responseindex 23c2c298ced..b82589019df 100644--- a/spec/fixtures/onebox/githubpullrequest.response+++ b/spec/fixtures/onebox/githubpullrequest.response@@ -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": {diff --git a/spec/lib/onebox/engine/github_pull_request_onebox_spec.rb b/spec/lib/onebox/engine/github_pull_request_onebox_spec.rbindex 3d983388e28..83f78976cb8 100644--- a/spec/lib/onebox/engine/github_pull_request_onebox_spec.rb+++ b/spec/lib/onebox/engine/github_pull_request_onebox_spec.rb@@ -21,6 +21,10 @@ RSpec.describe Onebox::Engine::GithubPullRequestOnebox doexpect(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" doexpect(html).to include("b3e9977094ce189bbb493cf7f9adea21")end