gfolf2/src/util/debug_version_info.gd

23 lines
644 B
GDScript3
Raw Normal View History

2024-12-17 15:54:59 -07:00
extends Label
## Label showing debug info about the game version.
## Branch info will not be printed on any of these branches.
const IGNORED_BRANCHES := ["main"]
func _ready() -> void:
# Fall back on baked version info
text = Game.settings.version
var output: Array[String] = []
var status := OS.execute("git", ["describe", "--always", "HEAD"], output)
if status == 0:
text = output[0].strip_edges()
output = []
status = OS.execute("git", ["branch", "--show-current"], output)
if status == 0:
var branch_name := output[0].strip_edges()
if branch_name and not branch_name in IGNORED_BRANCHES:
text += " (%s)" % branch_name