diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb260ee..ea307cc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -155,7 +155,11 @@ repos: types: [python] - id: flutter-analyze name: flutter analyze (workout app) - entry: bash -c 'cd stronglift_replacement/workout_app && flutter analyze' + # env -u GIT_DIR: git exports it to hooks, and flutter shells out to + # git to identify its own SDK -- with it set, flutter reads THIS repo + # as the SDK and pub resolves every constraint against 0.0.0-unknown. + entry: bash -c 'cd stronglift_replacement/workout_app && + env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE flutter analyze' language: system files: '^stronglift_replacement/workout_app/.*\.(dart|yaml)$' pass_filenames: false diff --git a/scripts/check_flutter_coverage.sh b/scripts/check_flutter_coverage.sh index 38513cc..67076a1 100755 --- a/scripts/check_flutter_coverage.sh +++ b/scripts/check_flutter_coverage.sh @@ -15,7 +15,11 @@ LCOV_INFO="$APP_DIR/coverage/lcov.info" cd "$APP_DIR" echo "Running flutter test --coverage ..." -flutter test --coverage +# env -u GIT_DIR: git exports it to hooks, and the flutter tool shells out to +# git to identify its own SDK. With it set, flutter reads THIS repository as +# the SDK -- reporting our HEAD as the framework revision -- and pub then +# resolves every version constraint against "0.0.0-unknown" and fails. +env -u GIT_DIR -u GIT_WORK_TREE -u GIT_INDEX_FILE flutter test --coverage cd - > /dev/null @@ -29,7 +33,7 @@ fi # Unreferenced files silently score 100% by absence — catch that here. missing=0 while IFS= read -r dart_file; do - rel="${dart_file#$APP_DIR/}" + rel="${dart_file#"$APP_DIR"/}" if ! grep -qF "SF:$rel" "$LCOV_INFO" && \ ! grep -qF "SF:lib/${rel#lib/}" "$LCOV_INFO"; then echo "MISSING FROM COVERAGE: $dart_file" >&2