Files
workspace/try_create_repo.py
aitest 15c4480db1 Add OpenClaw workspace configuration and tools
- Add agent configuration files (AGENTS.md, USER.md, IDENTITY.md, SOUL.md)
- Add git configuration and skills management scripts
- Add frontend/backend analysis tools and reports
- Add DingTalk media sender utilities and documentation
- Fix OpenClaw runtime environment (Node.js and Python)
- Configure git remotes and push scripts
2026-03-05 13:56:59 +09:00

54 lines
1.7 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""通过Git命令尝试创建远程仓库"""
import subprocess
import sys
# Git配置
GIT_SERVER = "git.alicorns.co.jp"
GIT_USER = "aitest"
REPONAME = "office-file-handler"
print("=== 尝试通过Git操作创建远程仓库 ===")
print(f"Git服务器: {GIT_SERVER}")
print(f"用户: {GIT_USER}")
print(f"仓库名: {REPONAME}")
print()
# 方法1: 尝试通过SSH创建裸仓库
print("方法1: 通过SSH创建裸仓库")
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(f"命令: {ssh_command}")
try:
result = subprocess.run(ssh_command, shell=True, capture_output=True, text=True, timeout=30)
print("输出:", result.stdout)
print("错误:", result.stderr)
if result.returncode == 0:
print("✓ SSH创建成功")
else:
print(f"SSH创建失败返回码: {result.returncode}")
except subprocess.TimeoutExpired:
print("✗ SSH连接超时")
except Exception as e:
print(f"✗ SSH错误: {e}")
print()
# 方法2: 尝试通过git命令查看服务器信息
print("方法2: 检查Git服务器信息")
try:
result = subprocess.run(["git", "ls-remote", f"https://{GIT_USER}@{GIT_SERVER}/test.git"],
capture_output=True, text=True, timeout=10)
print("ls-remote输出:", result.stdout)
print("ls-remote错误:", result.stderr)
except Exception as e:
print(f"✗ ls-remote错误: {e}")
print()
print("如果无法自动创建请在Git服务器Web界面上手动创建仓库")
print(f"1. 访问 https://{GIT_SERVER}/")
print(f"2. 创建仓库: {REPONAME}")
print("3. 然后使用git push命令推送代码")