阿里云云效 Codeup 代码仓库管理 - 查询项目、分支、提交记录等
通过个人访问令牌访问阿里云云效 Codeup 代码仓库。
在 ~/.zshrc 或 Gateway 环境变量中配置:
bash
export YUNXIAOPERSONALTOKEN=pt-xxx # 云效个人访问令牌
输入: 项目 URL 或路径
输出: 分支列表、统计信息
示例:
查看云效项目 https://codeup.aliyun.com/flashexpress/ard/be/tools/data-admin-api 的分支
输入: 项目 URL
输出: 项目名称、描述、成员数、最近活动
输入: 项目 URL + 分支名
输出: 最近提交记录、提交者、时间
输入: 项目 URL
输出: 各分支最后提交时间、活跃度排名
bash
优点:
缺点:
bash
优点:
缺点:
python
#!/usr/bin/env python3
阿里云云效 Codeup CLI 工具
import subprocess
import sys
import os
import tempfile
import shutil
from urllib.parse import urlparse
def get_token():
从环境变量获取令牌
token = os.getenv(YUNXIAOPERSONALTOKEN)
if not token:
print(❌ 错误:未配置 YUNXIAOPERSONALTOKEN 环境变量)
sys.exit(1)
return token
def parseprojecturl(url):
解析项目 URL
parsed = urlparse(url)
path = parsed.path.strip(/)
# 移除末尾的 /branches, /commits 等
if / in path:
parts = path.split(/)
if parts[-1] in [branches, commits, tree, blob]:
path = /.join(parts[:-1])
return path
def cloneandquery(url):
临时克隆并查询分支
token = get_token()
projectpath = parseproject_url(url)
# 创建临时目录
tmpdir = tempfile.mkdtemp(prefix=codeup)
reponame = projectpath.split(/)[-1]
repopath = os.path.join(tmpdir, repo_name)
try:
# 克隆仓库
giturl = fhttps://oauth2:{token}@codeup.aliyun.com/{projectpath}.git
subprocess.run(
[git, clone, --quiet, --depth=1, giturl, repopath],
check=True,
capture_output=True
)
# 查询分支
result = subprocess.run(
[git, branch, -a],
cwd=repo_path,
capture_output=True,
text=True,
check=True
)
# 解析分支列表
branches = []
for line in result.stdout.strip().split(\n):
if line.strip() and HEAD not in line:
branch = line.replace(*, ).replace(remotes/origin/, ).strip()
if branch:
branches.append(branch)
return {
success: True,
project: repo_name,
branches: sorted(branches),
total: len(branches)
}
except subprocess.CalledProcessError as e:
return {
success: False,
error: fGit 操作失败:{e.stderr.decode() if e.stderr else str(e)}
}
finally:
# 清理临时目录
if os.path.exists(tmp_dir):
shutil.rmtree(tmpdir, ignoreerrors=True)
def main():
if len(sys.argv) < 2:
print(用法:codeup_cli.py <项目 URL>)
print(示例:codeup_cli.py https://codeup.aliyun.com/flashexpress/ard/be/tools/data-admin-api)
sys.exit(1)
url = sys.argv[1]
result = cloneandquery(url)
if result[success]:
print(f✅ 项目:{result[project]})
print(f📊 分支总数:{result[total]})
print(\n分支列表:)
for branch in result[branches]:
print(f - {branch})
else:
print(f❌ 错误:{result[error]})
sys.exit(1)
if name == main:
main()
用户: 查看云效项目 https://codeup.aliyun.com/flashexpress/ard/be/tools/data-admin-api 的分支
执行:
bash
cd /tmp && rm -rf data-admin-api
git clone --quiet https://oauth2:$YUNXIAOPERSONALTOKEN@codeup.aliyun.com/flashexpress/ard/be/tools/data-admin-api.git
cd data-admin-api && git branch -a | grep -v HEAD | sed s/remotes\/origin\/// | sort
cd /tmp && rm -rf data-admin-api
输出:
📊 项目:data-admin-api
📊 分支总数:62
主分支:
- master
功能分支 (45):
- feature/common.20251211
- feature/common.20251105
- feature/20250730.geminifile
...
热修复分支 (15):
- hotfix/myj.250723
- hotfix/myj.batch
...
用户: 分析这个项目哪些分支最近有更新
执行:
bash
cd /tmp/data-admin-api
git branch -a --sort=-committerdate | head -20
输出:
📈 最近活跃的分支(按最后提交时间):
令牌需要以下权限:
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 aliyun-codeup-1776029823 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 aliyun-codeup-1776029823 技能
skillhub install aliyun-codeup-1776029823
文件大小: 6.88 KB | 发布时间: 2026-4-13 09:19