@@ -29,13 +29,16 @@ echo "[pre-commit] dotnet version: $(dotnet_cmd --version 2>&1)"
2929build_godotutils=false
3030build_visualize=false
3131build_packetgen=false
32+ build_optionsgen=false
3233
3334# Only run full solution validation when staged files can affect compilation.
3435requires_full_build=false
3536
3637echo " $STAGED " | grep -q " ^Template\.GodotUtils/" && build_godotutils=true || true
3738echo " $STAGED " | grep -q " ^Template\.Visualize/" && build_visualize=true || true
3839echo " $STAGED " | grep -q " ^Template\.PacketGen/" && build_packetgen=true || true
40+ echo " $STAGED " | grep -q " ^Template\.OptionsGen/" && build_optionsgen=true || true
41+ echo " $STAGED " | grep -Eq " \.cs$" && build_optionsgen=true || true
3942
4043# Visualize depends on GodotUtils
4144if $build_visualize ; then
@@ -59,7 +62,7 @@ done <<< "$STAGED"
5962if echo " $STAGED " | grep -q " ^\.editorconfig$" ; then
6063 echo " [pre-commit] Syncing .editorconfig to subprojects..."
6164
62- for dir in Template Template.GodotUtils Template.PacketGen Template.Visualize
65+ for dir in Template Template.GodotUtils Template.PacketGen Template.OptionsGen Template. Visualize
6366 do
6467 dest=" $REPO_ROOT /$dir /.editorconfig"
6568 cp " $REPO_ROOT /.editorconfig" " $dest "
@@ -154,6 +157,55 @@ if $build_packetgen; then
154157 git add " $LIBS /PacketGen.$next_version .nupkg"
155158fi
156159
160+ # ------------------------------------------------------------
161+ # Build Template.OptionsGen
162+ # ------------------------------------------------------------
163+ if $build_optionsgen ; then
164+ echo " [pre-commit] Building Template.OptionsGen..."
165+
166+ proj=" $REPO_ROOT /Template.OptionsGen/OptionsGen/OptionsGen.csproj"
167+ template_csproj=" $REPO_ROOT /Template/Template.csproj"
168+ out_dir=" $REPO_ROOT /Template.OptionsGen/OptionsGen/bin/Release"
169+
170+ current_version=" $( grep -o ' <Version>[^<]*</Version>' " $proj " | head -1 | sed ' s/<[^>]*>//g' ) "
171+
172+ next_version=" "
173+
174+ if [ -n " $current_version " ]; then
175+ major=" ${current_version%% .* } "
176+ rest=" ${current_version#* .} "
177+ minor=" ${rest%% .* } "
178+ patch=" ${rest#* .} "
179+
180+ next_version=" $major .$minor .$(( patch+ 1 )) "
181+
182+ sed -i " s|<Version>$current_version </Version>|<Version>$next_version </Version>|" " $proj "
183+ git add " $proj "
184+
185+ # Keep Template.csproj Template.OptionsGen reference in sync with the new version
186+ sed -i " s|<PackageReference Include=\" Template.OptionsGen\" Version=\" [^\" ]*\" |<PackageReference Include=\" Template.OptionsGen\" Version=\" $next_version \" |" " $template_csproj "
187+ git add " $template_csproj "
188+
189+ echo " [pre-commit] Template.OptionsGen version $current_version → $next_version "
190+ fi
191+
192+ # Stage deletion of any old tracked nupkgs and remove from filesystem before building
193+ git -C " $REPO_ROOT " rm --cached -f --ignore-unmatch " Template/Framework/Libraries/Template.OptionsGen.*.nupkg" 2> /dev/null || true
194+ find " $LIBS " -maxdepth 1 -name " Template.OptionsGen.*.nupkg" -delete || true
195+
196+ dotnet_cmd build " $proj " -c Release --no-restore
197+
198+ new_pkg=" $out_dir /Template.OptionsGen.$next_version .nupkg"
199+
200+ if [ ! -f " $new_pkg " ]; then
201+ echo " [pre-commit] ERROR: Template.OptionsGen nupkg not found at $new_pkg "
202+ exit 1
203+ fi
204+
205+ cp " $new_pkg " " $LIBS /"
206+ git add " $LIBS /Template.OptionsGen.$next_version .nupkg"
207+ fi
208+
157209# ------------------------------------------------------------
158210# Verify everything still works by building all projects
159211# ------------------------------------------------------------
0 commit comments