-
Couldn't load subscription status.
- Fork 0
fix(os-modules): improve shell script handling #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis change updates the shell scripting logic within the Possibly related PRs
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (2)
lib/os-modules/Taskfile.yaml (2)
46-56: 🛠️ Refactor suggestionEnsure robust error handling and safe variable expansions in the sync loop
Add
shell: bashand enable strict error handling (set -euo pipefail), and quote variable expansions to avoid word-splitting or unexpected behavior. Trim any leading/trailing whitespace withxargs.Apply this diff:
sync: + shell: bash cmds: - | + set -euo pipefail # Sanitize modules list: convert newlines to spaces, strip backslashes - modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g') + modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g' | xargs) - for module in $modules - do + for module in $modules; do echo "Syncing files to ../$module..." - for file in {{.FILES}} - do + for file in {{.FILES}}; do echo " Syncing $file" - rsync -av --delete {{.TMP_DIR}}/$file ../$module/ + rsync -av --delete "{{.TMP_DIR}}/${file}" "../${module}/" - done - done + done + done
74-86: 🛠️ Refactor suggestionAdd strict error handling and safe directory checks in pull-and-branch
Enable
bashwith strict mode, quote expansions, and guard against missing module directories to prevent unwanted failures:pull-and-branch: + shell: bash cmds: - | + set -euo pipefail # Sanitize modules list: convert newlines to spaces, strip backslashes - modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g') + modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g' | xargs) - for module in $modules - do + for module in $modules; do + if [ ! -d "../${module}" ]; then + echo "Module ../${module} not found, skipping" + continue + fi echo "🚀 Processing ../$module..." - cd ../$module + cd "../${module}" echo "⬇️ Pulling main branch..." git checkout main git pull origin main echo "🔄 Creating sync branch..." git checkout -b {{.SYNC_BRANCH}} - cd - - done + cd - >/dev/null + done
🧹 Nitpick comments (1)
lib/os-modules/Taskfile.yaml (1)
103-115: Handle no-op commits and improve error handling in push loopSkip modules with no changes to avoid commit errors, and add strict error handling with quoting:
push: + shell: bash cmds: - | + set -euo pipefail # Sanitize modules list: convert newlines to spaces, strip backslashes - modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g') + modules=$(echo "{{.MODULES}}" | tr '\n' ' ' | sed 's/\\//g' | xargs) - for module in $modules - do + for module in $modules; do echo "🚀 Processing ../$module..." - cd ../$module + cd "../${module}" + # Skip if no changes + if git diff --quiet; then + echo "No changes in ${module}, skipping commit/push" + cd - >/dev/null + continue + fi echo "📝 Committing changes..." git add . git commit -m "chore: update with the latest template state" echo "⬆️ Pushing changes..." git push origin {{.SYNC_BRANCH}} - cd - - done + cd - >/dev/null + done
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
lib/os-modules/Taskfile.yaml(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.yaml`: You are well-versed in writing and reviewing YAML configurations for the Task tool (https://taskfile.dev/). Provide recommendations for clarity, maintainability, and a...
**/*.yaml: You are well-versed in writing and reviewing YAML configurations for the Task tool (https://taskfile.dev/).
Provide recommendations for clarity, maintainability, and adherence to Taskfile best practices, including usage of variables, environment blocks, and includes.
These configurations may also contain embedded Bash scripts or commands.
Demonstrate bash scripting best practices such as error handling, secure variable expansions, and clear documentation.
lib/os-modules/Taskfile.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢
what
why
references
Summary by CodeRabbit