repo-manager/functions/clone.zsh

22 lines
608 B
Bash
Raw Normal View History

2024-10-08 01:35:43 +00:00
repo_clone() {
if [ -z "$2" ]; then
echo "Error: Repository path is required"
return 1
fi
local repo_prefix="$1"
cleaned=$(clean_repo_path "$2")
output_path="$REPO_BASE_DIR/$cleaned"
suffix=".git"
mkdir -p "${output_path%"$suffix"}"
2024-10-08 02:14:35 +00:00
if [ ! -d "${output_path%"$suffix"}/.git" ]; then
2024-10-08 01:35:43 +00:00
repourl=$(echo "$repo_prefix@$cleaned" | sed -e "s/\//:/1")
echo "Cloning $repourl to ${output_path%"$suffix"}..."
git clone "$repourl" "${output_path%"$suffix"}"
else
echo "Repository already exists: ${output_path%"$suffix"}"
fi
post_repo_clone "${output_path%"$suffix"}"
}