mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> Co-authored-by: Kashargul <KashL@t-online.de>
85 lines
2.9 KiB
Plaintext
85 lines
2.9 KiB
Plaintext
//GLOBAL_DATUM(revdata, /datum/getrev) // CHOMPEdit
|
|
|
|
/datum/getrev
|
|
var/branch
|
|
var/revision
|
|
var/date
|
|
var/showinfo
|
|
var/list/testmerge = list()
|
|
|
|
/datum/getrev/New()
|
|
if(world.TgsAvailable()) // Try TGS maybe
|
|
testmerge = world.TgsTestMerges()
|
|
var/datum/tgs_revision_information/REV = world.TgsRevision()
|
|
if(REV)
|
|
revision = REV.origin_commit || REV.commit
|
|
branch = "-Using TGS-" // TGS doesn't provide branch info yet
|
|
date = "-Using TGS-" // Or date
|
|
|
|
if(!revision) // File parse method
|
|
var/list/head_branch = file2list(".git/HEAD", "\n")
|
|
if(head_branch.len)
|
|
branch = copytext(head_branch[1], 17)
|
|
|
|
var/list/head_log = file2list(".git/logs/HEAD", "\n")
|
|
for(var/line=head_log.len, line>=1, line--)
|
|
if(head_log[line])
|
|
var/list/last_entry = splittext(head_log[line], " ")
|
|
if(last_entry.len < 2) continue
|
|
revision = last_entry[2]
|
|
// Get date/time
|
|
if(last_entry.len >= 5)
|
|
var/unix_time = text2num(last_entry[5])
|
|
if(unix_time)
|
|
date = unix2date(unix_time)
|
|
break
|
|
|
|
to_world_log("-Revision Info-")
|
|
to_world_log("Branch: [branch]")
|
|
to_world_log("Date: [date]")
|
|
to_world_log("Revision: [revision]")
|
|
|
|
/datum/getrev/proc/GetTestMergeInfo(header = TRUE)
|
|
. = list()
|
|
if(!testmerge.len)
|
|
return
|
|
if(header)
|
|
. += "The following pull requests are currently test merged:"
|
|
for(var/datum/tgs_revision_information/test_merge/tm as anything in testmerge)
|
|
var/cm = tm.head_commit //CHOMPStation Edit TGS4
|
|
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
|
|
. += "<a href=\"[CONFIG_GET(string/githuburl)]/pull/[tm.number]\">#[tm.number][details]</a>" // CHOMPEdit
|
|
|
|
/client/verb/showrevinfo()
|
|
set category = "OOC.Game" //CHOMPEdit
|
|
set name = "Show Server Revision"
|
|
set desc = "Check the current server code revision"
|
|
|
|
if(!GLOB.revdata)
|
|
to_chat(src, span_warning("Please wait until server initializations are complete."))
|
|
return
|
|
|
|
var/list/msg = list()
|
|
|
|
if(GLOB.revdata.revision)
|
|
msg += span_bold("Server revision:") + " B:[GLOB.revdata.branch] D:[GLOB.revdata.date]"
|
|
if(CONFIG_GET(string/githuburl)) // CHOMPEdit
|
|
msg += span_bold("Commit:") + " <a href='[CONFIG_GET(string/githuburl)]/commit/[GLOB.revdata.revision]'>[GLOB.revdata.revision]</a>" // CHOMPEdit
|
|
else
|
|
msg += span_bold("Commit:") + " [GLOB.revdata.revision]" // CHOMPEdit - Actually SHOW the revision
|
|
else
|
|
msg += span_bold("Server revision:") + " Unknown"
|
|
|
|
if(world.TgsAvailable())
|
|
var/datum/tgs_version/version = world.TgsVersion()
|
|
msg += span_bold("TGS version:") + " [version.raw_parameter]"
|
|
var/datum/tgs_version/api_version = world.TgsApiVersion()
|
|
msg += span_bold("DMAPI version:") + " [api_version.raw_parameter]"
|
|
|
|
if(GLOB.revdata.testmerge.len)
|
|
msg += GLOB.revdata.GetTestMergeInfo()
|
|
|
|
to_chat(src, msg.Join("<br>"))
|