-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-from-template.bat
More file actions
62 lines (51 loc) · 1.96 KB
/
Copy pathupdate-from-template.bat
File metadata and controls
62 lines (51 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@echo off
setlocal enabledelayedexpansion
echo [0/8] Cleaning stale rebase/merge state...
if exist ".git\rebase-merge" git rebase --abort >nul 2>&1
if exist ".git\MERGE_HEAD" git merge --abort >nul 2>&1
echo [1/8] Ensuring .gitattributes merge rules...
if not exist .gitattributes type nul > .gitattributes
for %%L in (
"update-from-template.bat merge=ours"
"src/data/meta.json merge=ours"
"src/data/laptime.json merge=ours"
"src/data/temp_laptime.json merge=ours"
"src/data/old_laptime.json merge=ours"
"data/personalbest.ini merge=ours"
"README.md merge=ours"
) do (
findstr /C:"%%~L" .gitattributes >nul || echo %%~L>>.gitattributes
)
echo [2/8] Committing .gitattributes if changed...
git status --porcelain .gitattributes | findstr /r ".*" >nul && (
git add .gitattributes
git commit -m "chore: ensure gitattributes merge rules" >nul 2>&1
)
echo [3/8] Checking for remote "upstream"...
set HAS_UPSTREAM=
for /f "tokens=1" %%r in ('git remote') do if /i "%%r"=="upstream" set HAS_UPSTREAM=1
if not defined HAS_UPSTREAM (
git remote add upstream https://github.com/yeftakun/ac-lapboard.git || goto :error
)
echo [4/8] Fetching changes from upstream and origin...
git fetch upstream || goto :error
git fetch origin || goto :error
git add . || goto :error
git commit -m "chore: prepare for update from template" || goto :error
echo [5/8] Merging upstream/master (preferring ours on conflicts)...
git merge -X ours upstream/master -m "update from template" || goto :error
echo [6/8] Merging origin/master (preferring ours on conflicts)...
git merge -X ours origin/master -m "sync with origin" || goto :error
echo [7/8] Showing status...
git status -sb
echo [8/8] Pushing to origin if ahead...
git push --force-with-lease || goto :error
echo(
echo Your web has been updated!
echo If there are changes, GitHub Actions will run the build workflow next...
set /p _="(Enter) "
goto :eof
:error
echo Update failed. Please check the git output above.
set /p _="(Enter) "
exit /b 1