Permission denied on git mv, used robocopy instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
76 lines
2.8 KiB
Python
76 lines
2.8 KiB
Python
"""Phase 2: Gitea 신규 저장소 생성 + 각 독립 repo push + GitHub remote 제거"""
|
|
import paramiko, sys, subprocess, os
|
|
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=15)
|
|
|
|
def run_server(label, cmd, timeout=30):
|
|
print(f' [{label}]')
|
|
_, o, e = client.exec_command(cmd, timeout=timeout)
|
|
out = o.read().decode('utf-8', errors='replace').strip()
|
|
if out: print(f' {out[:200]}')
|
|
return out
|
|
|
|
# 신규 Gitea 저장소 생성
|
|
NEW_REPOS = [
|
|
("guardia-manager", "GUARDiA 통합 관리자 포털"),
|
|
("guardia-messenger","GUARDiA Messenger 모바일 앱"),
|
|
("guardia-docs", "GUARDiA 프로젝트 문서 및 매뉴얼"),
|
|
]
|
|
print('[Gitea 신규 저장소 생성]')
|
|
for name, desc in NEW_REPOS:
|
|
run_server(f'create {name}', f"""
|
|
curl -sf -X POST 'http://localhost:3000/api/v1/user/repos' \
|
|
-u 'zio:Zio@Admin2026!' \
|
|
-H 'Content-Type: application/json' \
|
|
-d '{{"name":"{name}","description":"{desc}","private":false,"auto_init":false}}' \
|
|
2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('full_name','already exists or error'))" 2>/dev/null || echo 'exists/ok'
|
|
""")
|
|
|
|
client.close()
|
|
|
|
# 각 독립 repo에 Gitea remote 추가 + push
|
|
REPOS = {
|
|
"zioinfo-web": "zio/zioinfo-web",
|
|
"guardia-itsm": "zio/guardia-itsm",
|
|
"guardia-manager": "zio/guardia-manager",
|
|
"guardia-messenger":"zio/guardia-messenger",
|
|
"guardia-docs": "zio/guardia-docs",
|
|
}
|
|
|
|
print('\n[각 repo Gitea push]')
|
|
for local, gitea in REPOS.items():
|
|
path = f"C:/GUARDiA/repos/{local}"
|
|
url = f"http://zio:Zio%40Admin2026%21@101.79.17.164:3000/{gitea}.git"
|
|
print(f'\n {local} → {gitea}')
|
|
os.chdir(path)
|
|
# remote 설정
|
|
subprocess.run(['git', 'remote', 'remove', 'origin'], capture_output=True)
|
|
subprocess.run(['git', 'remote', 'add', 'origin', url], capture_output=True)
|
|
# main 브랜치로 push
|
|
r = subprocess.run(['git', 'push', 'origin', 'main', '--force'],
|
|
capture_output=True, text=True, timeout=120)
|
|
if r.returncode == 0:
|
|
print(f' OK push {local}')
|
|
else:
|
|
err = r.stderr.strip()[-200:] if r.stderr else ''
|
|
print(f' ERR: {err}')
|
|
|
|
# 모노레포에서 GitHub(origin) remote 제거
|
|
print('\n[GitHub remote(origin) 제거]')
|
|
os.chdir('C:/GUARDiA')
|
|
r = subprocess.run(['git', 'remote', 'remove', 'origin'], capture_output=True, text=True)
|
|
if r.returncode == 0:
|
|
print(' OK: origin(GitHub) 제거됨')
|
|
else:
|
|
print(f' {r.stderr.strip()}')
|
|
|
|
# 최종 remote 확인
|
|
r = subprocess.run(['git', 'remote', '-v'], capture_output=True, text=True)
|
|
print('\n[최종 remote 목록]')
|
|
print(r.stdout.strip())
|
|
|
|
print('\n=== Phase 2 완료 ===')
|