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
This commit is contained in:
65
create_git_repo_api.py
Normal file
65
create_git_repo_api.py
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""尝试通过Git API创建远程仓库"""
|
||||
|
||||
import requests
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Git配置
|
||||
GIT_SERVER = "git.alicorns.co.jp"
|
||||
GIT_USER = "aitest"
|
||||
GIT_PASSWORD = "Aitest123456"
|
||||
|
||||
# 尝试的API端点
|
||||
api_endpoints = [
|
||||
f"https://{GIT_SERVER}/api/v3/projects", # GitLab API
|
||||
f"https://{GIT_SERVER}/api/v4/projects", # GitLab API v4
|
||||
f"https://{GIT_USER}:{GIT_PASSWORD}@{GIT_SERVER}/api/v4/projects", # GitLab with auth
|
||||
]
|
||||
|
||||
print("=== 尝试通过API创建Git仓库 ===")
|
||||
print(f"Git服务器: {GIT_SERVER}")
|
||||
print(f"用户: {GIT_USER}")
|
||||
print()
|
||||
|
||||
# 尝试不同的API端点
|
||||
for i, url in enumerate(api_endpoints, 1):
|
||||
print(f"尝试API端点 {i}: {url}")
|
||||
try:
|
||||
# 尝试创建项目
|
||||
project_data = {
|
||||
"name": "office-file-handler",
|
||||
"visibility": "private"
|
||||
}
|
||||
|
||||
response = requests.post(url, json=project_data, timeout=10)
|
||||
print(f"状态码: {response.status_code}")
|
||||
|
||||
if response.status_code == 201:
|
||||
print("✓ 仓库创建成功!")
|
||||
print(f"响应: {response.json()}")
|
||||
sys.exit(0)
|
||||
elif response.status_code == 409:
|
||||
print("✓ 仓库已存在")
|
||||
sys.exit(0)
|
||||
else:
|
||||
print(f"响应: {response.text[:200]}")
|
||||
except Exception as e:
|
||||
print(f"错误: {e}")
|
||||
|
||||
print()
|
||||
|
||||
# 如果API方法失败,尝试通过命令行
|
||||
print("=== 尝试通过SSH创建仓库 ===")
|
||||
try:
|
||||
# 尝试SSH连接
|
||||
ssh_command = f"ssh {GIT_USER}@{GIT_SERVER} 'git init --bare /tmp/office-file-handler.git'"
|
||||
result = subprocess.run(ssh_command, shell=True, capture_output=True, text=True, timeout=30)
|
||||
print("SSH输出:", result.stdout)
|
||||
print("SSH错误:", result.stderr)
|
||||
except Exception as e:
|
||||
print(f"SSH错误: {e}")
|
||||
|
||||
print()
|
||||
print("如果以上方法都失败,需要手动在Git服务器上创建仓库或者使用Git Web界面。")
|
||||
Reference in New Issue
Block a user