작업실: 새 작품 이미지도 함께 커밋, 되돌리기 뒤 빈 폴더 정리
This commit is contained in:
1 parent
767b2a30a3
commit
ca2c0d077d
2 files changed
+22
-3
No files matched your search
+17
-1
@@ -188,6 +188,16 @@ def git_commit(message: str, paths: List[str]) -> Tuple[bool, str]:
|
||||
return ok, out.splitlines()[-1] if out else ""
|
||||
|
||||
|
||||
def prune_empty_image_dirs() -> None:
|
||||
"""비어 있는 작품 이미지 폴더를 정리한다(되돌리기 뒤 찌꺼기 방지)."""
|
||||
img_root = ASSETS / "img"
|
||||
if not img_root.is_dir():
|
||||
return
|
||||
for folder in sorted(img_root.iterdir()):
|
||||
if folder.is_dir() and not any(folder.iterdir()):
|
||||
folder.rmdir()
|
||||
|
||||
|
||||
def history(limit: int = 20) -> List[Dict[str, str]]:
|
||||
ok, out = git("log", f"-n{limit}", "--date=format:%Y-%m-%d %H:%M", "--pretty=format:%h\x1f%ad\x1f%s")
|
||||
if not ok:
|
||||
@@ -341,7 +351,12 @@ def save_product(payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||
return {"ok": False, "stage": "build", "error": error, "log": build_log}
|
||||
|
||||
label = "작품 추가" if creating else "작품 수정"
|
||||
committed, commit_log = git_commit(f"{label}: {data.get('title') or slug}", [str(path.relative_to(ROOT))])
|
||||
# md 와 그 작품의 이미지 폴더를 함께 커밋한다(새 이미지가 untracked 로 남지 않도록)
|
||||
paths = [str(path.relative_to(ROOT))]
|
||||
image_dir = ASSETS / "img" / slug
|
||||
if image_dir.is_dir():
|
||||
paths.append(str(image_dir.relative_to(ROOT)))
|
||||
committed, commit_log = git_commit(f"{label}: {data.get('title') or slug}", paths)
|
||||
if not committed:
|
||||
return {"ok": False, "stage": "git", "error": "git 커밋 실패 (파일은 저장됨)", "log": commit_log}
|
||||
|
||||
@@ -367,6 +382,7 @@ def revert(sha: str, redeploy: bool) -> Dict[str, Any]:
|
||||
if not ok:
|
||||
git("revert", "--abort")
|
||||
return {"ok": False, "error": "되돌리기 실패", "log": log}
|
||||
prune_empty_image_dirs()
|
||||
built, build_log = build()
|
||||
if not built:
|
||||
return {"ok": False, "error": "되돌린 뒤 빌드 실패", "log": build_log}
|
||||
|
||||
Reference in new issue
Block a user