Add git repo template script - #216
Conversation
WalkthroughAdds a new Bash script that copies a predefined set of configuration files from a source directory to a target repository template, preserving directory structure and creating destination directories as needed; the script uses strict shell options and prints each processed path. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant DevRepo as Source directory
participant Script as copy-repo-template.sh
participant Template as Target repository
DevRepo-->>Script: provide file list
Script->>Script: for each file\ncreate dest dir if missing
Script->>Template: copy file
Script-->>DevRepo: log processed path
Note over Script,Template: repeats for each configured file
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
scripts/copy-repo-template.sh (1)
30-33: Commented-out code suggests incomplete feature.The
files_to_toucharray is disabled and appears to represent future functionality. If this is not planned for the near term, consider removing it to reduce clutter. If it is planned, consider opening a tracking issue or adding a FIXME comment.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
scripts/copy-repo-template.sh(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.sh
📄 CodeRabbit inference engine (AGENTS.md)
Shell scripts must pass ShellCheck linting
Files:
scripts/copy-repo-template.sh
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: check
🔇 Additional comments (4)
scripts/copy-repo-template.sh (4)
1-2: Good use of defensive shell options.The shebang and
set -euo pipefailare appropriate for a production script, ensuring errors halt execution and unset variables are caught.
8-28: Array definition is clear and well-organized.The files array is logically grouped by category with helpful comments. The entries look reasonable for a repository template.
36-42: Copy loop lacks input validation and error context.The loop will fail silently if SOURCE or TARGET directories don't exist, or if a source file is missing. While
set -eensures the script exits on error, the error messages could be more informative.Consider adding validation and better error handling:
# Copy each file, preserving directory structure +if [[ ! -d "$SOURCE" ]]; then + echo "Error: SOURCE directory does not exist: $SOURCE" >&2 + exit 1 +fi + for file in "${files_to_copy[@]}"; do echo "$file" src="$SOURCE/$file" dst="$TARGET/$file" + if [[ ! -f "$src" ]]; then + echo "Error: Source file not found: $src" >&2 + exit 1 + fi mkdir -p "$(dirname "$dst")" cp "$src" "$dst" done
1-42: ShellCheck verification passed.The script passes ShellCheck linting and complies with the coding guidelines requirement.
6498530 to
88d1af4
Compare
Summary by CodeRabbit