49 lines
1.4 KiB
Python
49 lines
1.4 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
"""PRE-Backup Hotfix Lizenz-Erststart-Blocker 1.3.14."""
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import shutil
|
||
|
|
import subprocess
|
||
|
|
from datetime import datetime
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
ROOT = Path(__file__).resolve().parent
|
||
|
|
TS = datetime.now().strftime("%Y%m%d_%H%M%S")
|
||
|
|
BACKUP = ROOT / f"backup_hotfix_license_first_start_blocker_{TS}"
|
||
|
|
BACKUP.mkdir(parents=True, exist_ok=True)
|
||
|
|
|
||
|
|
FILES = [
|
||
|
|
"basis14.py",
|
||
|
|
"aza_start_panel.py",
|
||
|
|
"aza_version.py",
|
||
|
|
"version.json",
|
||
|
|
"release/version.json",
|
||
|
|
]
|
||
|
|
for rel in FILES:
|
||
|
|
src = ROOT / rel
|
||
|
|
if src.is_file():
|
||
|
|
dst = BACKUP / rel
|
||
|
|
dst.parent.mkdir(parents=True, exist_ok=True)
|
||
|
|
shutil.copy2(src, dst)
|
||
|
|
|
||
|
|
for name, cmd in [
|
||
|
|
("git_status_before.txt", ["git", "status", "--short"]),
|
||
|
|
("git_diff_stat_before.txt", ["git", "diff", "--stat"]),
|
||
|
|
("git_diff_before.patch", ["git", "diff"]),
|
||
|
|
]:
|
||
|
|
r = subprocess.run(cmd, cwd=ROOT, capture_output=True, text=True, check=False)
|
||
|
|
(BACKUP / name).write_text(r.stdout + r.stderr, encoding="utf-8")
|
||
|
|
|
||
|
|
(BACKUP / "README_RESTORE.txt").write_text(
|
||
|
|
f"""WIEDERHERSTELLUNG backup_hotfix_license_first_start_blocker
|
||
|
|
Erstellt: {TS}
|
||
|
|
Projektroot: {ROOT}
|
||
|
|
|
||
|
|
1. Dateien aus diesem Backup ins Projektroot kopieren (ueberschreibt Hotfix-Aenderungen)
|
||
|
|
2. Bei Bedarf aza_version.py / release/version.json auf 1.3.13 zuruecksetzen
|
||
|
|
3. Git: git_status_before.txt, git_diff_before.patch
|
||
|
|
""",
|
||
|
|
encoding="utf-8",
|
||
|
|
)
|
||
|
|
print(f"BACKUP_DIR={BACKUP}")
|