diff --git a/docs/development-log.md b/docs/development-log.md index ae7fc1a..af5c40a 100644 --- a/docs/development-log.md +++ b/docs/development-log.md @@ -1420,3 +1420,11 @@ This is the append-only implementation and handoff record shared by Codex and Cl - Live verification: installed on the SM-F966N; neither change was seen on the device by the implementer. - Next owner: the product owner, to confirm on the device. + +## 2026-09-28 (continued) — TASK-062: a batch file that syncs the main folder + +- Request: the human product owner asked for a batch file for the sync they run by hand. +- What changed: `tools/sync-main-folder.bat`. Fast-forward only; tracked changes stop it; files + in the way are stashed, never deleted; `master` is moved to the same commit. +- Verification: run three times against a throwaway clone (files in the way, already up to + date, uncommitted change). Not run against the main folder, which is the owner's to run. diff --git a/tools/sync-main-folder.bat b/tools/sync-main-folder.bat new file mode 100644 index 0000000..46f5e99 --- /dev/null +++ b/tools/sync-main-folder.bat @@ -0,0 +1,103 @@ +@echo off +rem Brings the main folder up to the branch the work is done on (TASK-062). +rem +rem sync-main-folder.bat [branch] [folder] +rem +rem It only ever moves forward (fast-forward). It never discards a change: if files in the main +rem folder are in the way, they are put in a stash, and the stash is named on screen. +chcp 65001 >nul +setlocal EnableExtensions + +set "BRANCH=claude/app-features-purpose-c45235" +set "MAIN=D:\Android\UBGitea" +if not "%~1"=="" set "BRANCH=%~1" +if not "%~2"=="" set "MAIN=%~2" +set "STASHED=" + +echo. +echo 메인 폴더 동기화 +echo 폴더 : %MAIN% +echo 가져올 작업 : %BRANCH% +echo. + +where git >nul 2>nul +if errorlevel 1 ( + echo [중단] git 을 찾을 수 없습니다. Git 이 설치되어 있는지 확인해 주세요. + goto :fail +) +if not exist "%MAIN%\.git" ( + echo [중단] %MAIN% 은 Git 저장소가 아닙니다. + goto :fail +) +git -C "%MAIN%" rev-parse --verify --quiet "%BRANCH%" >nul +if errorlevel 1 ( + echo [중단] %BRANCH% 브랜치가 없습니다. + goto :fail +) + +rem A change to a tracked file is someone's work in progress. It is not touched. +git -C "%MAIN%" diff --quiet +if errorlevel 1 goto :dirty +git -C "%MAIN%" diff --cached --quiet +if errorlevel 1 goto :dirty + +echo [1/3] 최신 작업으로 이동합니다. +git -C "%MAIN%" merge --ff-only "%BRANCH%" >nul 2>nul +if not errorlevel 1 goto :merged + +rem The usual reason: a file that the branch now tracks already lies in the folder, untracked. +echo 폴더에 있던 파일이 길을 막고 있어 임시 보관한 뒤 다시 시도합니다. +set "STASHED=main-folder-before-sync-%DATE%-%TIME%" +git -C "%MAIN%" stash push -u -m "%STASHED%" >nul +if errorlevel 1 ( + echo [중단] 임시 보관에 실패했습니다. + set "STASHED=" + goto :fail +) +git -C "%MAIN%" merge --ff-only "%BRANCH%" +if errorlevel 1 ( + echo. + echo [중단] 앞으로만 이동하는 방식으로는 합칠 수 없습니다. + echo 메인 폴더에 이 작업에 없는 커밋이 있는 경우입니다. 아무것도 바뀌지 않았습니다. + goto :fail +) + +:merged +echo [2/3] master 를 같은 위치로 맞춥니다. +for /f "delims=" %%b in ('git -C "%MAIN%" branch --show-current') do set "CURRENT=%%b" +if /i "%CURRENT%"=="master" ( + echo 지금 master 에 있으므로 이미 맞춰졌습니다. +) else ( + git -C "%MAIN%" branch -f master "%BRANCH%" >nul 2>nul + if errorlevel 1 echo [주의] master 를 옮기지 못했습니다. 다른 폴더에서 master 를 열어 둔 경우입니다. +) + +echo [3/3] 결과 +git -C "%MAIN%" log --oneline -3 +echo. +if defined STASHED ( + echo 임시 보관한 파일이 있습니다: "%STASHED%" + echo 최신 버전이 이미 들어 있으므로 보통은 꺼낼 필요가 없습니다. + echo 목록 보기: git -C "%MAIN%" stash list + echo. +) +echo 완료되었습니다. +echo. +pause +exit /b 0 + +:dirty +echo [중단] 메인 폴더에 저장하지 않은 수정이 있습니다. 아무것도 바꾸지 않았습니다. +echo 아래 파일을 커밋하거나 되돌린 뒤 다시 실행해 주세요. +echo. +git -C "%MAIN%" status --short + +:fail +echo. +if defined STASHED ( + echo 임시 보관한 파일이 있습니다: "%STASHED%" + echo 되돌리기: git -C "%MAIN%" stash pop + echo. +) +pause +exit /b 1