repo-manager/functions/clone.zsh
2024-10-07 18:35:43 -07:00

22 lines
596 B
Bash

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"}"
if [ ! -d "$output_path/.git" ]; then
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"}"
}