Skip to content

Commit

Permalink
try fetching trunk explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicente Canales committed Dec 12, 2023
1 parent 4a331e9 commit 4642115
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/add-strict-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ jobs:
- name: Check for new PHP files
id: check
run: |
git fetch origin trunk
NEW_PHP_FILES=$(git diff --name-only origin/trunk...HEAD -- '*.php' | xargs grep -LE 'declare\( strict_types=1\ )')
git fetch origin +refs/heads/trunk:refs/remotes/origin/trunk
NEW_PHP_FILES=$(git diff --name-only refs/remotes/origin/trunk HEAD -- '*.php' | xargs -r grep -LE 'declare\( strict_types=1 \)')
if [ -n "$NEW_PHP_FILES" ]; then
echo "::set-output name=strict_types_needed::true"
echo "New PHP files without strict types: $NEW_PHP_FILES"
else
echo "::set-output name=strict_types_needed::false"
fi
- name: Add strict types to new PHP files
if: steps.check.outputs.strict_types_needed == 'true'
run: |
git fetch origin trunk
for file in $(git diff --name-only origin/trunk...HEAD -- '*.php' | xargs grep -LE 'declare\( strict_types=1\ )'); do
git fetch origin trunk:trunk
for file in $(git diff --name-only origin/trunk...HEAD -- '*.php' | xargs grep -LE 'declare\( strict_types=1 \)'); do
sed -i '1s/^/<?php declare( strict_types=1 );\n/' "$file"
git add "$file"
done
Expand Down

0 comments on commit 4642115

Please sign in to comment.