- Move backend/frontend/messenger/ old paths to _archive/ - Reorganize scripts into scripts/deploy, check, push, setup, misc - Move docs (pptx, docx) to docs/ - Add .claude agents and skills for fullstack/folder-cleanup harness - workspace/ projects remain intact Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
106 lines
3.6 KiB
Python
106 lines
3.6 KiB
Python
"""나머지 repos push - 브랜치명 명시"""
|
|
import paramiko, sys, os, subprocess
|
|
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect('101.79.17.164', username='root', password='1q2w3e!Q', timeout=30)
|
|
sftp = client.open_sftp()
|
|
|
|
GITEA_AUTH_URL = 'zio:Zio%40Admin2026%21'
|
|
|
|
def run(label, cmd, timeout=300):
|
|
print(f' [{label}]')
|
|
_, o, e = client.exec_command(cmd, timeout=timeout)
|
|
out = o.read().decode('utf-8', errors='replace').strip()
|
|
err = e.read().decode('utf-8', errors='replace').strip()
|
|
if out: print(f' {out[-300:]}')
|
|
if err:
|
|
bad = [l for l in err.splitlines() if not any(k in l.lower() for k in ['warn','hint','cloning','into','updating','%'])]
|
|
if bad: print(f' ERR: {bad[-1]}')
|
|
return out
|
|
|
|
# 남은 repos: zioinfo-web, guardia-itsm, guardia-manager, guardia-docs
|
|
REMAINING = {
|
|
"zioinfo-web": ("zio/zioinfo-web", "main"),
|
|
"guardia-itsm": ("zio/guardia-itsm", "main"),
|
|
"guardia-manager": ("zio/guardia-manager", "main"),
|
|
"guardia-docs": ("zio/guardia-docs", "main"),
|
|
}
|
|
|
|
for local, (gitea, branch_name) in REMAINING.items():
|
|
local_path = f"C:/GUARDiA/repos/{local}"
|
|
server_path = f"/tmp/{local}_repo"
|
|
name = gitea.split('/')[1]
|
|
|
|
print(f'\n {local} → {gitea}')
|
|
|
|
# 로컬 브랜치 확인
|
|
r = subprocess.run(['git', '-C', local_path, 'branch'],
|
|
capture_output=True, text=True)
|
|
print(f' 브랜치: {r.stdout.strip()[:60]}')
|
|
|
|
# 번들 생성 (브랜치명 명시)
|
|
bundle_path = f"C:/GUARDiA/repos/{local}.bundle"
|
|
server_bundle = f"/tmp/{local}.bundle"
|
|
|
|
r = subprocess.run(
|
|
['git', '-C', local_path, 'bundle', 'create', bundle_path, f'refs/heads/{branch_name}'],
|
|
capture_output=True, text=True, timeout=120
|
|
)
|
|
if r.returncode != 0:
|
|
# HEAD로 재시도
|
|
r = subprocess.run(
|
|
['git', '-C', local_path, 'bundle', 'create', bundle_path, '--all'],
|
|
capture_output=True, text=True, timeout=120
|
|
)
|
|
if r.returncode != 0:
|
|
print(f' 번들 실패: {r.stderr[:100]}')
|
|
continue
|
|
|
|
size_mb = os.path.getsize(bundle_path) // (1024*1024)
|
|
print(f' bundle: {size_mb}MB')
|
|
sftp.put(bundle_path, server_bundle)
|
|
os.remove(bundle_path)
|
|
|
|
gitea_url = f"http://{GITEA_AUTH_URL}@127.0.0.1:9003/{gitea}.git"
|
|
run(f'push {local}', f"""
|
|
rm -rf /tmp/{name}_w
|
|
# bundle verify
|
|
git bundle verify {server_bundle} 2>&1 | head -3
|
|
|
|
# bundle의 refs 확인
|
|
REFS=$(git bundle list-heads {server_bundle} 2>/dev/null)
|
|
echo "refs: $REFS"
|
|
|
|
# fetch로 push
|
|
mkdir -p /tmp/{name}_w
|
|
cd /tmp/{name}_w
|
|
git init -b main 2>/dev/null
|
|
git fetch {server_bundle} 2>/dev/null
|
|
FETCH_HEAD=$(cat .git/FETCH_HEAD 2>/dev/null | head -1 | awk '{{print $1}}')
|
|
echo "FETCH_HEAD: $FETCH_HEAD"
|
|
|
|
if [ -n "$FETCH_HEAD" ]; then
|
|
git checkout -b main "$FETCH_HEAD" 2>/dev/null || git reset --hard "$FETCH_HEAD"
|
|
git remote add origin '{gitea_url}'
|
|
git push origin main --force 2>&1 | tail -3
|
|
else
|
|
echo "FETCH_HEAD 없음"
|
|
fi
|
|
|
|
rm -rf /tmp/{name}_w {server_bundle}
|
|
echo "완료"
|
|
""")
|
|
|
|
# 최종 확인
|
|
run('최종 확인', """
|
|
curl -sf 'http://127.0.0.1:9003/api/v1/repos/search?limit=20' \
|
|
-u 'zio:Zio@Admin2026!' 2>/dev/null | \
|
|
python3 -c "import sys,json; [print(r['full_name'], r.get('size',0),'KB') for r in json.load(sys.stdin).get('data',[])]"
|
|
""")
|
|
|
|
sftp.close()
|
|
client.close()
|
|
print('\n=== 완료 ===')
|