我的 Skill
clone-personal-gitlab
使用独立 SSH 身份安全克隆个人 GitLab 仓库,并设置仓库级提交身份。
- 克隆个人私有仓库
- 隔离个人与公司 Git 身份
- 初始化仓库提交信息
把它带到你的 Codex。
执行前需在本机配置 gitlab-personal SSH 身份,并拥有私有仓库访问权限。
显示安装命令
set -euo pipefail
skill_name='clone-personal-gitlab'
source_url='git@gitlab-personal:seven-grove/tools/personal-codex-skills.git'
source_ref='854e8cc87916742fc7cef130b8263342af8614f6'
source_subdirectory='skills/clone-personal-gitlab'
temp_root=$(mktemp -d)
backup_root="${CODEX_HOME:-$HOME/.codex}/skills-backups"
target_root="${CODEX_HOME:-$HOME/.codex}/skills"
backup_path=""
install_complete="0"
restore_previous() {
if [ "$install_complete" != "1" ]; then
rm -rf "$target_root/$skill_name"
if [ -n "$backup_path" ] && [ -d "$backup_path" ]; then
mv "$backup_path" "$target_root/$skill_name"
fi
fi
}
cleanup() { rm -rf "$temp_root"; }
trap 'restore_previous; cleanup' EXIT
git clone --filter=blob:none --no-checkout "$source_url" "$temp_root/repo"
git -C "$temp_root/repo" checkout "$source_ref" -- "$source_subdirectory"
test -f "$temp_root/repo/$source_subdirectory/SKILL.md"
mkdir -p "$target_root" "$backup_root"
if [ -e "$target_root/$skill_name" ]; then
backup_path="$backup_root/$skill_name-$(date +%Y%m%d-%H%M%S)"
mv "$target_root/$skill_name" "$backup_path"
fi
cp -R "$temp_root/repo/$source_subdirectory" "$target_root/$skill_name"
test -f "$target_root/$skill_name/SKILL.md"
install_complete="1"
printf 'Installed %s\n' "$target_root/$skill_name"
if [ -n "$backup_path" ]; then printf 'Backup %s\n' "$backup_path"; fi