mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-12 19:22:56 +00:00
Update revinfo proc
This commit is contained in:
@@ -5,40 +5,75 @@ var/global/datum/getrev/revdata = new()
|
|||||||
var/revision
|
var/revision
|
||||||
var/date
|
var/date
|
||||||
var/showinfo
|
var/showinfo
|
||||||
|
var/list/testmerge = list()
|
||||||
|
|
||||||
/datum/getrev/New()
|
/datum/getrev/New()
|
||||||
var/list/head_branch = file2list(".git/HEAD", "\n")
|
if(world.TgsAvailable()) // Try TGS maybe
|
||||||
if(head_branch.len)
|
testmerge = world.TgsTestMerges()
|
||||||
branch = copytext(head_branch[1], 17)
|
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")
|
var/list/head_log = file2list(".git/logs/HEAD", "\n")
|
||||||
for(var/line=head_log.len, line>=1, line--)
|
for(var/line=head_log.len, line>=1, line--)
|
||||||
if(head_log[line])
|
if(head_log[line])
|
||||||
var/list/last_entry = splittext(head_log[line], " ")
|
var/list/last_entry = splittext(head_log[line], " ")
|
||||||
if(last_entry.len < 2) continue
|
if(last_entry.len < 2) continue
|
||||||
revision = last_entry[2]
|
revision = last_entry[2]
|
||||||
// Get date/time
|
// Get date/time
|
||||||
if(last_entry.len >= 5)
|
if(last_entry.len >= 5)
|
||||||
var/unix_time = text2num(last_entry[5])
|
var/unix_time = text2num(last_entry[5])
|
||||||
if(unix_time)
|
if(unix_time)
|
||||||
date = unix2date(unix_time)
|
date = unix2date(unix_time)
|
||||||
break
|
break
|
||||||
|
|
||||||
to_world_log("Running revision:")
|
to_world_log("-Revision Info-")
|
||||||
to_world_log(branch)
|
to_world_log("Branch: [branch]")
|
||||||
to_world_log(date)
|
to_world_log("Date: [date]")
|
||||||
to_world_log(revision)
|
to_world_log("Revision: [revision]")
|
||||||
|
|
||||||
|
/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.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
|
||||||
|
. += "<a href=\"[config.githuburl]/pull/[tm.number]\">#[tm.number][details]</a><br>"
|
||||||
|
|
||||||
client/verb/showrevinfo()
|
client/verb/showrevinfo()
|
||||||
set category = "OOC"
|
set category = "OOC"
|
||||||
set name = "Show Server Revision"
|
set name = "Show Server Revision"
|
||||||
set desc = "Check the current server code revision"
|
set desc = "Check the current server code revision"
|
||||||
|
|
||||||
|
var/list/msg = list()
|
||||||
|
|
||||||
if(revdata.revision)
|
if(revdata.revision)
|
||||||
to_chat(src, "<b>Server revision:</b> [revdata.branch] - [revdata.date]")
|
msg += "<b>Server revision:</b> [revdata.branch] - [revdata.date]"
|
||||||
if(config.githuburl)
|
if(config.githuburl)
|
||||||
to_chat(src, "<a href='[config.githuburl]/commit/[revdata.revision]'>[revdata.revision]</a>")
|
msg += "<a href='[config.githuburl]/commit/[revdata.revision]'>[revdata.revision]</a>"
|
||||||
else
|
else
|
||||||
to_chat(src,revdata.revision)
|
to_chat(src,revdata.revision)
|
||||||
else
|
else
|
||||||
to_chat(src, "Revision unknown")
|
msg += "<b>Server revision:</b> Unknown"
|
||||||
|
|
||||||
|
if(world.TgsAvailable())
|
||||||
|
var/datum/tgs_version/version = world.TgsVersion()
|
||||||
|
msg += "TGS version: [version.raw_parameter]"
|
||||||
|
var/datum/tgs_version/api_version = world.TgsApiVersion()
|
||||||
|
msg += "DMAPI version: [api_version.raw_parameter]"
|
||||||
|
|
||||||
|
if(revdata.testmerge.len)
|
||||||
|
msg += revdata.GetTestMergeInfo()
|
||||||
|
|
||||||
|
to_chat(src, msg.Join("<br>"))
|
||||||
|
|||||||
Reference in New Issue
Block a user