From 193023cc3cb0a04c7c58464d7dac027dec41e6e5 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 1 Feb 2026 17:09:42 -0500 Subject: [PATCH] Check if the HEAD commit is publicly available on GitHub. If it is, set it in the database (#95043) ## 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 :cl: 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. /:cl: @nfreader --------- Co-authored-by: Jordan Dominion --- code/controllers/subsystem/ticker.dm | 2 +- code/datums/helper_datums/getrev.dm | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/code/controllers/subsystem/ticker.dm b/code/controllers/subsystem/ticker.dm index b254efc3fe4..05f2c5a59a3 100644 --- a/code/controllers/subsystem/ticker.dm +++ b/code/controllers/subsystem/ticker.dm @@ -324,7 +324,7 @@ SUBSYSTEM_DEF(ticker) var/arguments = list() if(GLOB.revdata.originmastercommit) to_set += "commit_hash = :commit_hash" - arguments["commit_hash"] = GLOB.revdata.originmastercommit + arguments["commit_hash"] = GLOB.revdata.GetDatabaseCommitSha() if(to_set.len) arguments["round_id"] = GLOB.round_id var/datum/db_query/query_round_game_mode = SSdbcore.NewQuery( diff --git a/code/datums/helper_datums/getrev.dm b/code/datums/helper_datums/getrev.dm index adb676acc2c..20ad08a77b6 100644 --- a/code/datums/helper_datums/getrev.dm +++ b/code/datums/helper_datums/getrev.dm @@ -41,6 +41,26 @@ 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 ""