Skip to content

Commit be9a8c8

Browse files
S34NWgithub-actions
and
github-actions
authored
Fix TGUI deconflict hooks, makes them work on windows (ParadiseSS13#24686)
* Lets us install tgui merge drivers on windows * test this * gamer mode * debug * do it like this * test * test this * stop it being weirdly relative * more relative fixes * try cat * indentation * update CI stuff to cache * correct this * yarn * yarn consistency * do we even need to do this? (no we don't) * properly cache yarn deps in ci * Why do we even have that step --------- Co-authored-by: github-actions <[email protected]>
1 parent 85792c0 commit be9a8c8

10 files changed

+67
-30
lines changed

.gitattributes

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
## Merger hooks, run tools/hooks/install.bat or install.sh to set up
1+
## Merge hooks, run tools/hooks/install.bat or install.sh to set up
22
*.dmm text eol=lf merge=dmm
33
*.dmi binary merge=dmi
4+
## TGUI bundle merge drivers
5+
*.bundle.* binary merge=tgui-merge-bundle
6+
*.chunk.* binary merge=tgui-merge-bundle

.github/workflows/ci.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,34 @@ jobs:
1414
runs-on: ubuntu-22.04
1515
steps:
1616
- uses: actions/checkout@v4
17+
1718
- name: Setup Cache
1819
uses: actions/cache@v4
1920
with:
2021
path: $HOME/SpacemanDMM
2122
key: ${{ runner.os }}-spacemandmm
23+
2224
- name: Install Tools
2325
run: |
2426
bash tools/ci/install_build_deps.sh
2527
bash tools/ci/install_dreamchecker.sh
28+
2629
- uses: actions/setup-python@v5
2730
with:
28-
python-version: '3.10'
31+
python-version: '3.11'
2932
cache: 'pip'
33+
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
cache: 'yarn'
38+
cache-dependency-path: ./tgui/yarn.lock
39+
3040
- run: pip install -r tools/requirements.txt
3141
- name: Run Linters
3242
run: |
3343
tools/ci/check_json.sh
34-
tools/ci/build_tgui.sh
44+
tgui/bin/tgui --ci
3545
python tools/ci/check_grep2.py
3646
python tools/ci/check_line_endings.py
3747
python tools/ci/check_file_names.py
@@ -41,6 +51,7 @@ jobs:
4151
python -m tools.ci.check_icon_conflicts
4252
python -m tools.ci.check_icon_dupenames
4353
python -m tools.maplint.source --github
54+
4455
- name: Run DreamChecker
4556
shell: bash
4657
run: ~/dreamchecker 2>&1 | bash tools/ci/annotate_dm.sh

.github/workflows/merge_upstream_master.yml

+7
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@ jobs:
2020
ref: ${{ env.PR_BRANCH }}
2121
fetch-depth: 0
2222

23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
cache: 'yarn'
27+
cache-dependency-path: ./tgui/yarn.lock
28+
2329
- uses: actions/setup-python@v5
2430
with:
2531
python-version: '3.11'
32+
cache: 'pip'
2633

2734
- name: Perform Merge
2835
run: |

tgui/.gitattributes

-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,5 @@ yarn.lock text eol=lf
1717
bin/tgui text eol=lf
1818

1919
## Treat bundles as binary and ignore them during conflicts
20-
*.bundle.* binary merge=tgui-merge-bundle
21-
*.chunk.* binary merge=tgui-merge-bundle
2220
.yarn/releases/**/* binary
2321
.yarn/plugins/**/* binary

tgui/bin/tgui

+13-7
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,24 @@ task-install-git-hooks() {
125125
git_root="$(git rev-parse --show-toplevel)"
126126
git_base_dir="${base_dir/${git_root}/.}"
127127
git config --replace-all merge.tgui-merge-bundle.driver \
128-
"${git_base_dir}/bin/tgui --merge=bundle %O %A %B %L"
128+
"${git_base_dir}/tgui/bin/tgui --merge=bundle %P %O %A %B %L"
129129
echo "tgui: Merge drivers have been successfully installed!"
130130
}
131131

132132
## Bundle merge driver
133133
task-merge-bundle() {
134-
local file_ancestor="${1}"
135-
local file_current="${2}"
136-
local file_other="${3}"
137-
local conflict_marker_size="${4}"
138-
echo "tgui: Discarding a local tgui build"
139-
## Do nothing (file_current will be merged and is what we want to keep).
134+
local file_path="${1}"
135+
local file_ancestor="${2}"
136+
local file_current="${3}"
137+
local file_other="${4}"
138+
local conflict_marker_size="${5}"
139+
echo "----------------------"
140+
echo "tgui: rebuilding a conflicted tgui bundle, ${file_path}"
141+
task-install
142+
task-webpack --mode=production
143+
echo "tgui: replacing conflicted bundle with newly compiled bundle"
144+
cd ../
145+
cat $file_path > $file_current
140146
exit 0
141147
}
142148

tgui/bin/tgui_.ps1

+12
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,13 @@ function task-validate-build {
104104
Write-Output "tgui: build is ok"
105105
}
106106

107+
## Installs merge drivers and git hooks
108+
function task-install-git-hooks () {
109+
Set-Location $global:basedir
110+
git config --replace-all merge.tgui-merge-bundle.driver "tgui/bin/tgui --merge=bundle %P %O %A %B %L"
111+
Write-Output "tgui: Merge drivers have been successfully installed!"
112+
}
113+
107114
## Main
108115
## --------------------------------------------------------
109116

@@ -113,6 +120,11 @@ if ($Args.Length -gt 0) {
113120
exit 0
114121
}
115122

123+
if ($Args[0] -eq "--install-git-hooks") {
124+
task-install-git-hooks
125+
exit 0
126+
}
127+
116128
if ($Args[0] -eq "--dev") {
117129
$Rest = $Args | Select-Object -Skip 1
118130
task-install

tools/ci/build_tgui.sh

-10
This file was deleted.

tools/ci/install_build_deps.sh

-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
#!/bin/bash
22
set -euo pipefail
33

4-
source _build_dependencies.sh
5-
6-
source ~/.nvm/nvm.sh
7-
nvm install $NODE_VERSION
8-
nvm use $NODE_VERSION
9-
npm install --global yarn
104
python3 -m pip install json5
11-

tools/hooks/Install.bat

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
11
@call "%~dp0\..\bootstrap\python" -m hooks.install %*
2-
@pause
2+
@echo off
3+
set /p choice=Do you want to install TGUI hooks (requires Node.js)? (Y/N):
4+
5+
if /i "%choice%"=="Y" (
6+
@echo off
7+
rem Copyright (c) 2020 Aleksej Komarov
8+
rem SPDX-License-Identifier: MIT
9+
call powershell.exe -NoLogo -ExecutionPolicy Bypass -File "%~dp0\..\..\tgui\bin\tgui_.ps1" --install-git-hooks %*
10+
rem Pause if launched in a separate shell unless initiated from powershell
11+
echo %PSModulePath% | findstr %USERPROFILE% >NUL
12+
if %errorlevel% equ 0 (
13+
pause
14+
exit 0
15+
)
16+
echo %cmdcmdline% | find /i "/c"
17+
)
18+
pause

tools/hooks/Uninstall.bat

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
@call "%~dp0\..\bootstrap\python" -m hooks.install --uninstall %*
2+
git config --unset merge.tgui-merge-bundle.driver
23
@pause

0 commit comments

Comments
 (0)