From 05afc4f52ca2aa2adfa0b0932cf1db1a62bb5bd3 Mon Sep 17 00:00:00 2001 From: carnie Date: Wed, 20 Mar 2013 04:31:02 +0000 Subject: [PATCH] Substitute for the getrev code. Unfortunately, it only fetches the commit-hash for HEAD. This should be sufficient for our needs though. Signed-off-by: carnie --- code/datums/helper_datums/getrev.dm | 108 +++++++--------------------- code/game/gamemodes/game_mode.dm | 2 +- code/world.dm | 2 +- 3 files changed, 26 insertions(+), 86 deletions(-) diff --git a/code/datums/helper_datums/getrev.dm b/code/datums/helper_datums/getrev.dm index d9ccc2e5b7e..4ebbacb4b99 100644 --- a/code/datums/helper_datums/getrev.dm +++ b/code/datums/helper_datums/getrev.dm @@ -2,99 +2,39 @@ * This datum gets revision info from local svn 'entries' file * Path to the directory containing it should be in 'config/svndir.txt' file * - */ - -var/global/datum/getrev/revdata // = new("config/svndir.txt") //commented out until the git revcount stuff is ready + */ +var/global/datum/getrev/revdata = new() //Oh yeah, I'm an OOP fag, lalala /datum/getrev + var/project_href = "https://www.github.com/tgstation/-tg-station" var/revision - var/commiter - var/svndirpath - var/revhref + var/showinfo - proc/abort() - world.log << "Unable to get revision info." - spawn() - del src - - New(filename) - ..() - var/list/Lines = file2list(filename) - if(!Lines.len) return abort() - for(var/t in Lines) - if(!t) continue - t = trim(t) - if (length(t) == 0) - continue - else if (copytext(t, 1, 2) == "#") - continue - var/pos = findtext(t, " ") - var/name = null - var/value = null - if (pos) - name = lowertext(copytext(t, 1, pos)) - value = copytext(t, pos + 1) - else - name = lowertext(t) - if(!name) - continue - switch(name) - if("svndir") - svndirpath = value - if("revhref") - revhref = value - - if(svndirpath && fexists(svndirpath) && fexists("[svndirpath]/entries") && isfile(file("[svndirpath]/entries"))) - var/list/filelist = file2list("[svndirpath]/entries") - var/s_archive = "" //Stores the previous line so the revision owner can be assigned. - - //This thing doesn't count blank lines, so doing filelist[4] isn't working. - for(var/s in filelist) - if(!commiter) - if(s == "has-props")//The line before this is the committer. - commiter = s_archive - if(!revision) - var/n = text2num(s) - if(isnum(n)) - if(n > 5000 && n < 99999) //Do you think we'll still be up and running at r100000? :) ~Errorage - revision = s - if(revision && commiter) - break - s_archive = s - if(!revision) - abort() - world.log << "Running TG Revision Number: [revision]." - diary << "Revision info loaded succesfully" - return - return abort() - - proc/getRevisionText() - var/output - if(revhref) - output = {"[revision]"} + New() + 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 = text2list(head_log[line], " ") + if(last_entry.len < 2) continue + revision = last_entry[2] + break + + showinfo = "Server Revision: " + if(revision) + showinfo += "[revision]" else - output = revision - return output - - proc/showInfo() - return {" - - - -

Server Revision: [getRevisionText()]
- Author: [commiter]

- - "} + showinfo += "*unknown*" + showinfo += "

-Report Bugs Here-
Please provide as much info as possible
Copy/paste the revision hash into your issue report if possible, thanks
:)

" + + world.log << "Running TG Revision Number: [revision]." + return client/verb/showrevinfo() set category = "OOC" set name = "Show Server Revision" - var/output = "Sorry, the revision info is unavailable.
" - if(revdata) - output = revdata.showInfo() - - output += "Current Infomational Settings:
" - output += "Protect Authority Roles From Tratior: [config.protect_roles_from_antagonist]
" + var/output = revdata.showinfo + output += "Current Infomational Settings:
" + output += "Protect Authority Roles From Traitor: [config.protect_roles_from_antagonist]
" usr << browse(output,"window=revdata"); return diff --git a/code/game/gamemodes/game_mode.dm b/code/game/gamemodes/game_mode.dm index 675836ffc33..b94a1af94a4 100644 --- a/code/game/gamemodes/game_mode.dm +++ b/code/game/gamemodes/game_mode.dm @@ -103,7 +103,7 @@ Whitespace:Seperator; feedback_set_details("round_start","[time2text(world.realtime)]") if(ticker && ticker.mode) feedback_set_details("game_mode","[ticker.mode]") - if(revdata) + if(revdata.revision) feedback_set_details("revision","[revdata.revision]") feedback_set_details("server_ip","[world.internet_address]:[world.port]") return 1 diff --git a/code/world.dm b/code/world.dm index de0cdc2ab6b..41ef45c11c6 100644 --- a/code/world.dm +++ b/code/world.dm @@ -138,7 +138,7 @@ n++ s["players"] = n - if(revdata) s["revision"] = revdata.revision + s["revision"] = revdata.revision s["admins"] = admins return list2params(s)