mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-10 15:45:05 +01:00
193023cc3c
## About The Pull Request TGS provides two SHA's to the game. The first is the closest commit on the tracked branch (`master`) the second is the true revision of the game. The latter may be equal to the first, but not when test merges are active. We normally set the database `commit_hash` to the first because we can't guarantee the latter is on GitHub. TGS **does** try to push it there however (i.e. https://github.com/tgstation/tgstation/commit/b7c18d2bdb6b091255716fa801113be4d73be987) provided it has proper credentials. This PR will ping the HEAD SHA on GitHub to see if it exists there. If it does, it'll be set as the round's `commit_hash`. ## Why It's Good For The Game Allows statbus to link to the EXACT commit of the round which includes test merges. Currently it lies when test merges are active by linking the `master` commit. ## Changelog 🆑 server: If TGS is configured to push test merge commits to a publicly accessible GitHub, the exact game revision will be set as the `round`.`commit_hash` in the database. /🆑 @nfreader --------- Co-authored-by: Jordan Dominion <Cyberboss@users.noreply.github.com>
112 lines
4.1 KiB
Plaintext
112 lines
4.1 KiB
Plaintext
/datum/getrev
|
|
var/commit // git rev-parse HEAD
|
|
var/date
|
|
var/originmastercommit // git rev-parse origin/master
|
|
var/list/testmerge = list()
|
|
|
|
/datum/getrev/New()
|
|
commit = rustg_git_revparse("HEAD")
|
|
if(commit)
|
|
date = rustg_git_commit_date(commit)
|
|
originmastercommit = rustg_git_revparse("origin/master")
|
|
|
|
/datum/getrev/proc/load_tgs_info()
|
|
testmerge = world.TgsTestMerges()
|
|
var/datum/tgs_revision_information/revinfo = world.TgsRevision()
|
|
if(revinfo)
|
|
commit = revinfo.commit
|
|
originmastercommit = revinfo.origin_commit
|
|
date = revinfo.timestamp || rustg_git_commit_date(commit)
|
|
|
|
// goes to DD log and config_error.txt
|
|
log_world(get_log_message())
|
|
|
|
/datum/getrev/proc/get_log_message()
|
|
var/list/msg = list()
|
|
msg += "Running /tg/ revision: [date]"
|
|
if(originmastercommit)
|
|
msg += "origin/master: [originmastercommit]"
|
|
|
|
for(var/line in testmerge)
|
|
var/datum/tgs_revision_information/test_merge/tm = line
|
|
msg += "Test merge active of PR #[tm.number] commit [tm.head_commit]"
|
|
SSblackbox.record_feedback("associative", "testmerged_prs", 1, list("number" = "[tm.number]", "commit" = "[tm.head_commit]", "title" = "[tm.title]", "author" = "[tm.author]"))
|
|
|
|
if(commit && commit != originmastercommit)
|
|
msg += "HEAD: [commit]"
|
|
else if(!originmastercommit)
|
|
msg += "No commit information"
|
|
|
|
msg += "Running rust-g version [rustg_get_version()]"
|
|
|
|
return msg.Join("\n")
|
|
|
|
/datum/getrev/proc/GetDatabaseCommitSha()
|
|
. = originmastercommit
|
|
if (commit == .)
|
|
return .
|
|
|
|
var/gh_url = CONFIG_GET(string/githuburl)
|
|
if(!gh_url)
|
|
return .
|
|
|
|
var/datum/http_request/request = new()
|
|
request.prepare(RUSTG_HTTP_METHOD_GET, "[gh_url]/commit/[commit]", "", "")
|
|
request.begin_async()
|
|
UNTIL(request.is_complete())
|
|
var/datum/http_response/response = request.into_response()
|
|
|
|
if (response.status_code >= 200 && response.status_code < 300)
|
|
return commit
|
|
|
|
return .
|
|
|
|
/datum/getrev/proc/GetTestMergeInfo(header = TRUE)
|
|
if(!testmerge.len)
|
|
return ""
|
|
. = header ? "The following pull requests are currently test merged:<br>" : ""
|
|
for(var/line in testmerge)
|
|
var/datum/tgs_revision_information/test_merge/tm = line
|
|
var/cm = tm.head_commit
|
|
var/details = ": '" + html_encode(tm.title) + "' by " + html_encode(tm.author) + " at commit " + html_encode(copytext_char(cm, 1, 11))
|
|
. += "<a href=\"[CONFIG_GET(string/githuburl)]/pull/[tm.number]\">#[tm.number][details]</a><br>"
|
|
|
|
/client/verb/showrevinfo()
|
|
set category = "OOC"
|
|
set name = "Show Server Revision"
|
|
set desc = "Check the current server code revision"
|
|
|
|
var/list/msg = list()
|
|
// Round ID
|
|
if(GLOB.round_id)
|
|
msg += "<b>Round ID:</b> [GLOB.round_id]"
|
|
|
|
msg += "<b>BYOND Version:</b> [world.byond_version].[world.byond_build]"
|
|
if(DM_VERSION != world.byond_version || DM_BUILD != world.byond_build)
|
|
msg += "<b>Compiled with BYOND Version:</b> [DM_VERSION].[DM_BUILD]"
|
|
|
|
// Revision information
|
|
var/datum/getrev/revdata = GLOB.revdata
|
|
msg += "<b>Server revision compiled on:</b> [revdata.date]"
|
|
var/pc = revdata.originmastercommit
|
|
if(pc)
|
|
msg += "<b>Master commit:</b> <a href=\"[CONFIG_GET(string/githuburl)]/commit/[pc]\">[pc]</a>"
|
|
if(length(revdata.testmerge))
|
|
msg += revdata.GetTestMergeInfo()
|
|
if(revdata.commit && revdata.commit != revdata.originmastercommit)
|
|
msg += "<b>Local commit:</b> [revdata.commit]"
|
|
else if(!pc)
|
|
msg += "No commit information"
|
|
if(world.TgsAvailable())
|
|
var/datum/tgs_version/version = world.TgsVersion()
|
|
msg += "<b>TGS version</b>: [version.raw_parameter]"
|
|
msg += "<b>DMAPI version</b>: [TGS_DMAPI_VERSION]"
|
|
|
|
// Game mode odds
|
|
msg += "<br><b>Current Informational Settings:</b>"
|
|
msg += "<b>Protect Authority Roles From Traitor:</b> [CONFIG_GET(flag/protect_roles_from_antagonist) ? "Yes" : "No"]"
|
|
msg += "<b>Protect Assistant Role From Traitor:</b> [CONFIG_GET(flag/protect_assistant_from_antagonist) ? "Yes" : "No"]"
|
|
msg += "<b>Enforce Human Authority:</b> [CONFIG_GET(string/human_authority) ? "Yes" : "No"]"
|
|
msg += "<b>Allow Latejoin Antagonists:</b> [CONFIG_GET(flag/allow_latejoin_antagonists) ? "Yes" : "No"]"
|
|
to_chat(src, fieldset_block("Server Revision Info", span_infoplain(jointext(msg, "<br>")), "boxed_message"), type = MESSAGE_TYPE_INFO)
|