Skip to content

Commit 5759931

Browse files
ostermanclaude
andcommitted
fix: correct bash syntax for handling newline-separated file lists
- Fix loop syntax to properly handle newline-separated output from gh pr view - Deduplicate directories when running tests to avoid redundant test runs - Use proper quoting and read -r for robust file path handling - Test all commands to ensure they work correctly 🤖 Generated with Claude Code Co-Authored-By: Claude <[email protected]>
1 parent 9483e2c commit 5759931

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

.claude/agents/pr-review-handler.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ gh pr view $PR_NUMBER --repo cloudposse/atmos --json files,title,state
165165

166166
# 2. Get list of changed files (for targeted linting)
167167
CHANGED_FILES=$(gh pr view $PR_NUMBER --repo cloudposse/atmos --json files --jq '.files[].path')
168-
echo "Changed files: $CHANGED_FILES"
168+
echo "Changed files:"
169+
echo "$CHANGED_FILES"
169170

170171
# 3. Get all review comments
171172
gh pr view $PR_NUMBER --repo cloudposse/atmos --comments > pr_comments.txt
@@ -232,19 +233,24 @@ Only after user approval:
232233
make lint # This already uses --new-from-rev=origin/main
233234

234235
# 2. Apply specific fixes to changed files only
235-
for file in $CHANGED_FILES; do
236+
echo "$CHANGED_FILES" | while read -r file; do
236237
if [[ $file == *.go ]]; then
237238
# Format only if it's a Go file that was changed
238-
gofumpt -w $file
239-
goimports -w $file
239+
gofumpt -w "$file"
240+
goimports -w "$file"
240241
fi
241242
done
242243

243-
# 3. Run tests for changed packages
244-
for file in $CHANGED_FILES; do
244+
# 3. Run tests for changed packages (deduplicate directories)
245+
CHANGED_DIRS=$(echo "$CHANGED_FILES" | while read -r file; do
245246
if [[ $file == *.go ]]; then
246-
pkg_dir=$(dirname $file)
247-
go test ./$pkg_dir -v
247+
dirname "$file"
248+
fi
249+
done | sort -u)
250+
251+
echo "$CHANGED_DIRS" | while read -r pkg_dir; do
252+
if [[ -n $pkg_dir ]]; then
253+
go test "./$pkg_dir" -v
248254
fi
249255
done
250256

0 commit comments

Comments
 (0)