Files
crank/scripts/export-community.sh
T
2026-05-07 19:21:12 +00:00

36 lines
766 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
usage() {
cat <<'EOF'
Usage:
./scripts/export-community.sh /path/to/crank-community-working-tree
The target directory must already be a git working tree for crank-community.
EOF
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
exit 0
fi
if [[ $# -ne 1 ]]; then
usage >&2
exit 1
fi
repo_root="$(git rev-parse --show-toplevel)"
target_dir="$(cd "$1" && pwd)"
if [[ ! -d "$target_dir/.git" ]]; then
echo "target is not a git working tree: $target_dir" >&2
exit 1
fi
find "$target_dir" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
git -C "$repo_root" ls-files -z -- . ':(exclude)templates/repositories/**' \
| rsync -a --delete --from0 --files-from=- "$repo_root/" "$target_dir/"