#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Try to create remote repository""" import subprocess import sys # Git configuration GIT_SERVER = "git.alicorns.co.jp" GIT_USER = "aitest" REPONAME = "office-file-handler" print("=== Try to create remote repository ===") print("Git server:", GIT_SERVER) print("User:", GIT_USER) print("Repository:", REPONAME) print() # Method 1: Try SSH to create bare repository print("Method 1: SSH to create bare repository") ssh_command = f'ssh -o StrictHostKeyChecking=no -o ConnectTimeout=10 {GIT_USER}@{GIT_SERVER} "mkdir -p /git/{REPONAME}.git && cd /git/{REPONAME}.git && git init --bare"' print("Command:", ssh_command) try: result = subprocess.run(ssh_command, shell=True, capture_output=True, text=True, timeout=30) print("Output:", result.stdout) print("Error:", result.stderr) if result.returncode == 0: print("SUCCESS: SSH creation worked!") else: print("FAILED: SSH creation failed, return code:", result.returncode) except subprocess.TimeoutExpired: print("FAILED: SSH connection timeout") except Exception as e: print("FAILED: SSH error:", e) print() # Method 2: Check git server info print("Method 2: Check git server info") try: result = subprocess.run(["git", "ls-remote", f"https://{GIT_USER}@{GIT_SERVER}/"], capture_output=True, text=True, timeout=10) print("ls-remote output:", result.stdout[:200] if result.stdout else "empty") print("ls-remote error:", result.stderr[:200] if result.stderr else "empty") except Exception as e: print("FAILED: ls-remote error:", e) print() print("If automatic creation fails, please create repository manually:") print("1. Visit https://" + GIT_SERVER + "/") print("2. Create repository: " + REPONAME) print("3. Then use git push to upload code")