feat(client): Version helper + sync-version script; project.godot config/version
- Add scripts/sync-version to sync root /VERSION into client/project.godot - Add Version GDScript helper (reads application/config/version) - Test coverage: 2 tests for Version.string() and footer() - Synced config/version="0.01-alpha" to project.godot Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="coc-rpg"
|
||||
config/version="0.01-alpha"
|
||||
config/description="AI-driven single-player party RPG. Code owns state. AI owns text."
|
||||
config/features=PackedStringArray("4.7")
|
||||
|
||||
|
||||
18
client/scripts/util/version.gd
Normal file
18
client/scripts/util/version.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
class_name Version
|
||||
extends RefCounted
|
||||
## The client's view of the single source of truth (/VERSION, charter §4). The
|
||||
## value is baked into project.godot's application/config/version by
|
||||
## scripts/sync-version on each bump; read it via ProjectSettings so an exported
|
||||
## build (which has no repo-root /VERSION) still knows its own version.
|
||||
|
||||
const SETTING := "application/config/version"
|
||||
const LAST_RESORT := "0.0.0-dev"
|
||||
|
||||
|
||||
func string() -> String:
|
||||
var v := str(ProjectSettings.get_setting(SETTING, ""))
|
||||
return v if v != "" else LAST_RESORT
|
||||
|
||||
|
||||
func footer() -> String:
|
||||
return "v%s · BUILT IN GODOT 4.7 · © 2026" % string()
|
||||
1
client/scripts/util/version.gd.uid
Normal file
1
client/scripts/util/version.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://xyvm7nhkf8be
|
||||
13
client/tests/unit/test_version.gd
Normal file
13
client/tests/unit/test_version.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
extends "res://addons/gut/test.gd"
|
||||
|
||||
|
||||
func test_string_matches_project_setting():
|
||||
var expected := str(ProjectSettings.get_setting("application/config/version", ""))
|
||||
assert_ne(expected, "", "project.godot must carry application/config/version (run scripts/sync-version)")
|
||||
assert_eq(Version.new().string(), expected)
|
||||
|
||||
|
||||
func test_footer_contains_version_and_engine():
|
||||
var v := Version.new()
|
||||
assert_string_contains(v.footer(), v.string())
|
||||
assert_string_contains(v.footer(), "BUILT IN GODOT 4.7")
|
||||
1
client/tests/unit/test_version.gd.uid
Normal file
1
client/tests/unit/test_version.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://co7wtt67t2p7d
|
||||
13
scripts/sync-version
Executable file
13
scripts/sync-version
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
# Sync the single source of truth (/VERSION) into the Godot client's project.godot
|
||||
# (application/config/version). Run after bumping /VERSION.
|
||||
set -euo pipefail
|
||||
root="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
version="$(tr -d '[:space:]' < "$root/VERSION")"
|
||||
proj="$root/client/project.godot"
|
||||
if grep -q '^config/version=' "$proj"; then
|
||||
sed -i "s|^config/version=.*|config/version=\"$version\"|" "$proj"
|
||||
else
|
||||
sed -i "s|^\(config/name=.*\)|\1\nconfig/version=\"$version\"|" "$proj"
|
||||
fi
|
||||
echo "synced client config/version = \"$version\""
|
||||
Reference in New Issue
Block a user