diff --git a/code/__DEFINES/rust_g.dm b/code/__DEFINES/rust_g.dm index ad6f95a8654..7fdd53dde30 100644 --- a/code/__DEFINES/rust_g.dm +++ b/code/__DEFINES/rust_g.dm @@ -12,7 +12,7 @@ #define rustg_noise_get_at_coordinates(seed, x, y) call(RUST_G, "noise_get_at_coordinates")(seed, x, y) -// Git related operations // - AA TODO: Add in in-code revision parsing +// Git related operations // #define rustg_git_revparse(rev) call(RUST_G, "rg_git_revparse")(rev) #define rustg_git_commit_date(rev) call(RUST_G, "rg_git_commit_date")(rev) diff --git a/code/datums/revision.dm b/code/datums/revision.dm new file mode 100644 index 00000000000..b5eb5d05a79 --- /dev/null +++ b/code/datums/revision.dm @@ -0,0 +1,56 @@ +GLOBAL_DATUM_INIT(revision_info, /datum/code_revision, new) +GLOBAL_PROTECT(revision_info) // Dont mess with this + +/** + * Code Revision Datum + * + * Allows the server code to be aware of the Git environment it is running in, and lets commit hash be viewed + */ +/datum/code_revision + /// Current commit hash the server is running + var/commit_hash + /// Date that this commit was made + var/commit_date + +/datum/code_revision/New() + commit_hash = rustg_git_revparse("HEAD") + if(commit_hash) + commit_date = rustg_git_commit_date(commit_hash) + +/** + * Code Revision Logging Helper + * + * Small proc to simplify logging all this stuff + */ +/datum/code_revision/proc/log_info() + // Put revision info in the world log + var/logmsg + if(commit_hash && commit_date) + logmsg = "Running ParaCode commit: [commit_hash] (Date: [commit_date])" + else + logmsg = "Unable to determine revision info! Code may not be running in a git repository." + + // Log it in all these + log_world(logmsg) + log_runtime_txt(logmsg) + log_runtime_summary(logmsg) + +/client/verb/get_revision_info() + set name = "Get Revision Info" + set category = "OOC" + set desc = "Retrieve technical information about the server" + + var/list/msg = list() + msg += "Server Revision Info" + // Commit info first + if(GLOB.revision_info.commit_hash && GLOB.revision_info.commit_date) + msg += "Server Commit: [GLOB.revision_info.commit_hash] (Date: [GLOB.revision_info.commit_date])" + else + msg += "Server Commit: Unable to determine" + + // Show server BYOND version + msg += "Server BYOND Version: [world.byond_version].[world.byond_build]" + // And the clients for good measure + msg += "Client (your) BYOND Version: [byond_version].[byond_build]" + + to_chat(usr, msg.Join("
")) diff --git a/code/game/world.dm b/code/game/world.dm index a25ba837cc3..bb19ac745cc 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -10,6 +10,7 @@ GLOBAL_LIST_INIT(map_transition_config, MAP_TRANSITION_CONFIG) TgsNew(new /datum/tgs_event_handler/impl, TGS_SECURITY_TRUSTED) // creates a new TGS object log_world("World loaded at [time_stamp()]") log_world("[GLOB.vars.len - GLOB.gvars_datum_in_built_vars.len] global variables") + GLOB.revision_info.log_info() connectDB() // This NEEDS TO HAPPEN EARLY. I CANNOT STRESS THIS ENOUGH!!!!!!! -aa load_admins() // Same here diff --git a/paradise.dme b/paradise.dme index 1f4ae631087..631e5fc9ea8 100644 --- a/paradise.dme +++ b/paradise.dme @@ -297,6 +297,7 @@ #include "code\datums\progressbar.dm" #include "code\datums\radio.dm" #include "code\datums\recipe.dm" +#include "code\datums\revision.dm" #include "code\datums\ruins.dm" #include "code\datums\shuttles.dm" #include "code\datums\soullink.dm"