@@ -442,7 +442,7 @@ function copy-skills() {
442442 for skill in " ${DEFAULT_SKILLS[@]} " ; do
443443 local skill_dir=" ${SKILLS_DIR} /${skill} "
444444 if [[ -d " ${skill_dir} " ]]; then
445- cp -R " ${skill_dir} " " ${dest_skills} /"
445+ copy-directory-excluding-git " ${skill_dir} " " ${dest_skills} /${skill} "
446446 fi
447447 done
448448
@@ -454,7 +454,7 @@ function copy-skills() {
454454 if [[ -n " ${skill} " ]]; then
455455 local skill_dir=" ${SKILLS_DIR} /${skill} "
456456 if [[ -d " ${skill_dir} " ]]; then
457- cp -R " ${skill_dir} " " ${dest_skills} /"
457+ copy-directory-excluding-git " ${skill_dir} " " ${dest_skills} /${skill} "
458458 fi
459459 fi
460460 fi
@@ -560,6 +560,26 @@ function copy-workspace-file() {
560560 fi
561561}
562562
563+ # Copy a directory without bringing across any nested .git metadata.
564+ # Arguments (provided as function parameters):
565+ # $1=[source directory path]
566+ # $2=[destination directory path]
567+ function copy-directory-excluding-git() {
568+
569+ local source_dir=" $1 "
570+ local target_dir=" $2 "
571+
572+ mkdir -p " ${target_dir} "
573+
574+ if command -v rsync > /dev/null 2>&1 ; then
575+ rsync -a --exclude=' .git' --exclude=' .git/' " ${source_dir} /" " ${target_dir} /"
576+ else
577+ tar -C " ${source_dir} " --exclude=' .git' -cf - . | tar -C " ${target_dir} " -xf -
578+ fi
579+
580+ return 0
581+ }
582+
563583# Print usage information.
564584function print-usage() {
565585
0 commit comments