From ec30c15cdc5f045eeb1360af3fa170ca19a6d16e Mon Sep 17 00:00:00 2001 From: runyaga Date: Sun, 8 Feb 2026 12:39:24 -0600 Subject: [PATCH] fix(hooks): add dart fix step and worktree-safe wrappers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two fixes for pre-commit hooks: 1. dart format can wrap long argument lists to multiple lines without adding trailing commas. flutter analyze --fatal-infos then rejects the result due to require_trailing_commas. Adding dart fix --apply as the first hook step closes this gap. 2. Git sets GIT_DIR in worktrees, which breaks Flutter's version detection (reports 0.0.0-unknown). Wrapper scripts in scripts/ unset GIT_DIR before calling dart/flutter commands. Hook order: dart fix → dart format → flutter analyze --- .pre-commit-config.yaml | 15 +++++++++++---- scripts/dart-fix.sh | 6 ++++++ scripts/dart-format.sh | 6 ++++++ scripts/flutter-analyze.sh | 7 +++++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100755 scripts/dart-fix.sh create mode 100755 scripts/dart-format.sh create mode 100755 scripts/flutter-analyze.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0ac22bea..64b07f56 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,16 +13,23 @@ repos: - id: gitleaks - repo: local hooks: + - id: dart-fix + name: dart fix + entry: scripts/dart-fix.sh + language: script + types: [dart] + exclude: ^packages/soliplex_client/lib/src/schema/ - id: dart-format name: dart format - entry: dart format --set-exit-if-changed - language: system + entry: scripts/dart-format.sh --set-exit-if-changed + language: script types: [dart] exclude: ^packages/soliplex_client/lib/src/schema/ - id: flutter-analyze name: flutter analyze - entry: flutter analyze --fatal-infos - language: system + entry: scripts/flutter-analyze.sh --fatal-infos + language: script + types: [dart] pass_filenames: false - id: dart-analyze-packages name: dart analyze packages diff --git a/scripts/dart-fix.sh b/scripts/dart-fix.sh new file mode 100755 index 00000000..bbda74d9 --- /dev/null +++ b/scripts/dart-fix.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Workaround for Dart SDK resolution in git worktrees. +# See flutter-analyze.sh for details. +unset GIT_DIR +unset GIT_WORK_TREE +exec dart fix --apply "$@" diff --git a/scripts/dart-format.sh b/scripts/dart-format.sh new file mode 100755 index 00000000..f3800498 --- /dev/null +++ b/scripts/dart-format.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Workaround for Dart SDK resolution in git worktrees. +# See flutter-analyze.sh for details. +unset GIT_DIR +unset GIT_WORK_TREE +exec dart format "$@" diff --git a/scripts/flutter-analyze.sh b/scripts/flutter-analyze.sh new file mode 100755 index 00000000..b7c84178 --- /dev/null +++ b/scripts/flutter-analyze.sh @@ -0,0 +1,7 @@ +#!/bin/sh +# Workaround for Flutter SDK version resolution in git worktrees. +# Git sets GIT_DIR in worktrees, which confuses Flutter's version detection +# (reports 0.0.0-unknown). Unsetting it restores correct behavior. +unset GIT_DIR +unset GIT_WORK_TREE +exec flutter analyze "$@"