Skip to content

HOTFIX: Set fetch-depth to 0 for the phpstan check#144

Merged
AdamJHall merged 1 commit into
mainfrom
hotfix/Fix-Checkout-History
May 3, 2026
Merged

HOTFIX: Set fetch-depth to 0 for the phpstan check#144
AdamJHall merged 1 commit into
mainfrom
hotfix/Fix-Checkout-History

Conversation

@AdamJHall
Copy link
Copy Markdown
Contributor

Description of the proposed changes
Currently the phpstan check is failing silently as it cannot get a diff of what files have changed. This along with an updated script in the repo should allow phpstan to start working again in github.

#!/bin/bash

# Detect environment and get changed PHP files accordingly
if [ "${GITHUB_ACTIONS}" = "true" ]; then
    # CI: diff against PR base branch
    BASE_REF="${GITHUB_BASE_REF:-production}"
    git fetch origin "$BASE_REF" --depth=1
    PHP_FILES=$(git diff --name-only --diff-filter=AM "origin/${BASE_REF}...HEAD" -- '*.php' '*.phtml')
else
    # Local pre-commit hook (cghooks): diff against staged index
    PHP_FILES=$(git diff --name-only --cached --diff-filter=AM -- '*.php' '*.phtml')
fi

if [[ -z "$PHP_FILES" ]]; then
    echo "Nothing to analyse"
else
    ./vendor/bin/phpstan analyse -c php.neon $PHP_FILES
fi

Notes to reviewers

ℹ️ When you've finished leaving feedback, please add a final comment to the PR tagging the author, letting them know that you have finished leaving feedback

…n.sh scripts can access the target branch to determine the diffed files
@AdamJHall AdamJHall merged commit 0daaff9 into main May 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants