From 420122854198d19c6704003b4384077db314e5f1 Mon Sep 17 00:00:00 2001 From: Bobbahbrown Date: Wed, 25 Nov 2020 17:16:47 -0400 Subject: [PATCH] Fixes template use for 'Report Issue' button in-game + show [s] testmerged prs (#55135) Fixed and improved the bug report template use when the 'Report Issue' button is used in-game. It now uses the correct template location, as well as automatically filling in the round ID and testmerges. We also now show [s] PRs that are testmerged, as ok-d by oranges, as this is an unofficial label that anyone can apply and doesn't necessitate hiding. It also makes debugging rounds where this was present but not reported more difficult. --- code/datums/helper_datums/getrev.dm | 2 -- interface/interface.dm | 31 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/code/datums/helper_datums/getrev.dm b/code/datums/helper_datums/getrev.dm index 91b8e325661..3c29a5ab169 100644 --- a/code/datums/helper_datums/getrev.dm +++ b/code/datums/helper_datums/getrev.dm @@ -47,8 +47,6 @@ var/datum/tgs_revision_information/test_merge/tm = line var/cm = tm.pull_request_commit var/details = ": '" + html_encode(tm.title) + "' by " + html_encode(tm.author) + " at commit " + html_encode(copytext_char(cm, 1, 11)) - if(details && findtext(details, "\[s\]") && (!usr || !usr.client.holder)) - continue . += "#[tm.number][details]
" /client/verb/showrevinfo() diff --git a/interface/interface.dm b/interface/interface.dm index 440f6e39b30..251cb934ff1 100644 --- a/interface/interface.dm +++ b/interface/interface.dm @@ -67,11 +67,32 @@ // then the report issue button being tgui-based would be problematic. if(tgalert(src, message, "Report Issue","Yes","No")!="Yes") return - var/static/issue_template = file2text(".github/ISSUE_TEMPLATE.md") - var/servername = CONFIG_GET(string/servername) - var/url_params = "Reporting client version: [byond_version].[byond_build]\n\n[issue_template]" - if(GLOB.round_id || servername) - url_params = "Issue reported from [GLOB.round_id ? " Round ID: [GLOB.round_id][servername ? " ([servername])" : ""]" : servername]\n\n[url_params]" + + // Keep a static version of the template to avoid reading file + var/static/issue_template = file2text(".github/ISSUE_TEMPLATE/bug_report.md") + + // Get a local copy of the template for modification + var/local_template = issue_template + + // Remove comment header + var/content_start = findtext(local_template, "<") + if(content_start) + local_template = copytext(local_template, content_start) + + // Insert round + if(GLOB.round_id) + local_template = replacetext(local_template, "## Round ID:\n", "## Round ID:\n[GLOB.round_id]") + + // Insert testmerges + if(GLOB.revdata.testmerge.len) + var/list/all_tms = list() + for(var/entry in GLOB.revdata.testmerge) + var/datum/tgs_revision_information/test_merge/tm = entry + all_tms += "- \[[tm.title]\]([githuburl]/pull/[tm.number])" + var/all_tms_joined = all_tms.Join("\n") // for some reason this can't go in the [] + local_template = replacetext(local_template, "## Testmerges:\n", "## Testmerges:\n[all_tms_joined]") + + var/url_params = "Reporting client version: [byond_version].[byond_build]\n\n[local_template]" DIRECT_OUTPUT(src, link("[githuburl]/issues/new?body=[url_encode(url_params)]")) else to_chat(src, "The Github URL is not set in the server configuration.")