Skip to content

Commit

Permalink
Merge pull request tgstation#40167 from AutomaticFrenzy/patch/rustg-git
Browse files Browse the repository at this point in the history
Use rust-g for revision info instead of parsing .git
  • Loading branch information
Cyberboss authored Sep 16, 2018
2 parents 11c1ca3 + 9cab6e5 commit c056136
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 55 deletions.
3 changes: 3 additions & 0 deletions code/__DEFINES/rust_g.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@

#define rustg_dmi_strip_metadata(fname) call(RUST_G, "dmi_strip_metadata")(fname)

#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)

#define rustg_log_write(fname, text) call(RUST_G, "log_write")(fname, text)
/proc/rustg_log_close_all() return call(RUST_G, "log_close_all")()
111 changes: 57 additions & 54 deletions code/datums/helper_datums/getrev.dm
Original file line number Diff line number Diff line change
@@ -1,44 +1,40 @@
/datum/getrev
var/originmastercommit
var/commit
var/list/testmerge = list()
var/commit // git rev-parse HEAD
var/date
var/originmastercommit // git rev-parse origin/master
var/list/testmerge = list()

/datum/getrev/New()
testmerge = world.TgsTestMerges()
log_world("Running /tg/ revision:")
var/datum/tgs_revision_information/revinfo = world.TgsRevision()
if(revinfo)
commit = revinfo.commit
originmastercommit = revinfo.origin_commit
else
var/list/logs = world.file2list(".git/logs/HEAD")
if(logs.len)
logs = splittext(logs[logs.len - 1], " ")
date = unix2date(text2num(logs[5]))
commit = logs[2]
log_world("[commit]: [date]")
else
log_world("Unable to read git logs, revision information not available")
originmastercommit = commit = "Unknown"
date = unix2date(world.timeofday)
return
logs = world.file2list(".git/logs/refs/remotes/origin/master")
if(logs.len)
originmastercommit = splittext(logs[logs.len - 1], " ")[2]
commit = rustg_git_revparse("HEAD")
if(commit)
date = rustg_git_commit_date(commit)
originmastercommit = rustg_git_revparse("origin/master")

// goes to DD log and config_error.txt
log_world(get_log_message())

if(testmerge.len)
log_world(commit)
for(var/line in testmerge)
if(line)
var/datum/tgs_revision_information/test_merge/tm = line
var/tmcommit = tm.commit
log_world("Test merge active of PR #[tm.number] commit [tmcommit]")
SSblackbox.record_feedback("nested tally", "testmerged_prs", 1, list("[tm.number]", "[tmcommit]"))
if(originmastercommit)
log_world("Based off origin/master commit [originmastercommit]")
else if(originmastercommit)
log_world(originmastercommit)
/datum/getrev/proc/get_log_message()
var/list/msg = list()
msg += "Running /tg/ revision: [date]"
if(originmastercommit)
msg += "origin/master: [originmastercommit]"

for(var/line in testmerge)
var/datum/tgs_revision_information/test_merge/tm = line
msg += "Test merge active of PR #[tm.number] commit [tm.commit]"

if(commit && commit != originmastercommit)
msg += "HEAD: [commit]"
else if(!originmastercommit)
msg += "No commit information"

return msg.Join("\n")

/datum/getrev/proc/GetTestMergeInfo(header = TRUE)
if(!testmerge.len)
Expand All @@ -57,28 +53,34 @@
set name = "Show Server Revision"
set desc = "Check the current server code revision"

var/list/msg = list("")
// Round ID
if(GLOB.round_id)
to_chat(src, "<b>Round ID:</b> [GLOB.round_id]")
if(GLOB.revdata.originmastercommit)
to_chat(src, "<b>Server revision compiled on:</b> [GLOB.revdata.date]")
var/prefix = ""
if(GLOB.revdata.testmerge.len)
to_chat(src, GLOB.revdata.GetTestMergeInfo())
prefix = "Based off origin/master commit: "
var/pc = GLOB.revdata.originmastercommit
to_chat(src, "[prefix]<a href=\"[CONFIG_GET(string/githuburl)]/commit/[pc]\">[copytext(pc, 1, min(length(pc), 11))]</a>")
else
to_chat(src, "Master revision unknown")
to_chat(src, "Revision: [GLOB.revdata.commit]")
msg += "<b>Round ID:</b> [GLOB.round_id]"

// Revision information
var/datum/getrev/revdata = GLOB.revdata
msg += "<b>Server revision compiled on:</b> [revdata.date]"
var/pc = revdata.originmastercommit
if(pc)
msg += "Master commit: <a href=\"[CONFIG_GET(string/githuburl)]/commit/[pc]\">[pc]</a>"
if(revdata.testmerge.len)
msg += revdata.GetTestMergeInfo()
if(revdata.commit && revdata.commit != revdata.originmastercommit)
msg += "Local commit: [revdata.commit]"
else if(!pc)
msg += "No commit information"
if(world.TgsAvailable())
to_chat(src, "Server tools version: [world.TgsVersion()]")
to_chat(src, "<b>Current Informational Settings:</b>")
to_chat(src, "Protect Authority Roles From Traitor: [CONFIG_GET(flag/protect_roles_from_antagonist)]")
to_chat(src, "Protect Assistant Role From Traitor: [CONFIG_GET(flag/protect_assistant_from_antagonist)]")
to_chat(src, "Enforce Human Authority: [CONFIG_GET(flag/enforce_human_authority)]")
to_chat(src, "Allow Latejoin Antagonists: [CONFIG_GET(flag/allow_latejoin_antagonists)]")
to_chat(src, "Enforce Continuous Rounds: [length(CONFIG_GET(keyed_list/continuous))] of [config.modes.len] roundtypes")
to_chat(src, "Allow Midround Antagonists: [length(CONFIG_GET(keyed_list/midround_antag))] of [config.modes.len] roundtypes")
msg += "Server tools version: [world.TgsVersion()]"

// Game mode odds
msg += "<br><b>Current Informational Settings:</b>"
msg += "Protect Authority Roles From Traitor: [CONFIG_GET(flag/protect_roles_from_antagonist)]"
msg += "Protect Assistant Role From Traitor: [CONFIG_GET(flag/protect_assistant_from_antagonist)]"
msg += "Enforce Human Authority: [CONFIG_GET(flag/enforce_human_authority)]"
msg += "Allow Latejoin Antagonists: [CONFIG_GET(flag/allow_latejoin_antagonists)]"
msg += "Enforce Continuous Rounds: [length(CONFIG_GET(keyed_list/continuous))] of [config.modes.len] roundtypes"
msg += "Allow Midround Antagonists: [length(CONFIG_GET(keyed_list/midround_antag))] of [config.modes.len] roundtypes"
if(CONFIG_GET(flag/show_game_type_odds))
var/list/probabilities = CONFIG_GET(keyed_list/probability)
if(SSticker.IsRoundInProgress())
Expand All @@ -99,17 +101,18 @@
probs[ctag] = 1
prob_sum += probabilities[ctag]
if(current_odds_differ)
to_chat(src, "<b>Game Mode Odds for current round:</b>")
msg += "<b>Game Mode Odds for current round:</b>"
for(var/ctag in probs)
if(probabilities[ctag] > 0)
var/percentage = round(probabilities[ctag] / prob_sum * 100, 0.1)
to_chat(src, "[ctag] [percentage]%")
msg += "[ctag] [percentage]%"

to_chat(src, "<b>All Game Mode Odds:</b>")
msg += "<b>All Game Mode Odds:</b>"
var/sum = 0
for(var/ctag in probabilities)
sum += probabilities[ctag]
for(var/ctag in probabilities)
if(probabilities[ctag] > 0)
var/percentage = round(probabilities[ctag] / sum * 100, 0.1)
to_chat(src, "[ctag] [percentage]%")
msg += "[ctag] [percentage]%"
to_chat(src, msg.Join("<br>"))
5 changes: 5 additions & 0 deletions code/game/world.dm
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ GLOBAL_VAR(restart_counter)
if(GLOB.round_id)
log_game("Round ID: [GLOB.round_id]")

// This was printed early in startup to the world log and config_error.log,
// but those are both private, so let's put the commit info in the runtime
// log which is ultimately public.
log_runtime(GLOB.revdata.get_log_message())

/world/Topic(T, addr, master, key)
TGS_TOPIC //redirect to server tools if necessary

Expand Down
2 changes: 1 addition & 1 deletion dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export BYOND_MAJOR=512
export BYOND_MINOR=1448

#rust_g git tag
export RUST_G_VERSION=0.4.0
export RUST_G_VERSION=0.4.1

#bsql git tag
export BSQL_VERSION=v1.4.0.0
Expand Down
Binary file modified rust_g.dll
Binary file not shown.

0 comments on commit c056136

Please sign in to comment.