Refactor git status parsing into reusable utilities#189
Closed
bestdan wants to merge 2 commits into
Closed
Conversation
…sues Add explicit null guards after ensureCondition calls (which exit but don't narrow types) and add undefined checks for regex match destructuring in both codeowners and graphql check commands. Fix Prettier formatting in 3 files.
Keep TypeScript null-safety fixes and Prettier formatting while merging upstream changes.
3 tasks
bestdan
added a commit
that referenced
this pull request
Mar 28, 2026
## Summary - **Fix 6 TypeScript errors** in `codeowners/check.ts` and `graphql/check.ts`: Add explicit null guards after `ensureCondition()` calls (which call `process.exit` but don't narrow types), and add undefined checks for regex match destructuring of `state`/`rawPath` - **Fix Prettier formatting** in 3 files: line length violations in `codeowners/check.ts`, `graphql/check.ts`, and `upgrade.test.ts` ## Test plan - [x] `pnpm typecheck` passes (0 errors) - [x] `pnpm lint` passes (ESLint + Prettier) - [x] `pnpm format:check` passes Supersedes #189 (rebased onto correct base branch). https://claude.ai/code/session_01RobTdhpRAXuPkyQ8CknbWd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR refactors duplicated git status parsing logic into shared utility functions and improves type safety in git-based checks. The changes eliminate code duplication between the GraphQL and CODEOWNERS checks while making the parsing logic more robust and maintainable.
Key Changes
parseGitStatusEntries()andgetNewlyChangedFiles()utility functions used by bothdartHookGraphqlCheckandgitCodeownersCheckisGraphqlOwnedFile()andisCodeownersFile()predicates to filter changed files by typeensureCondition()calls, with v8 ignore comments for coverageparseGitStatusEntries()function properly handles git rename operations (paths with->) by extracting the destination pathCOMMON_DART_CODEGEN_SUFFIXESto filter only GraphQL-relevant generated files (.gql.dartand.fakes.dart)versionparameter inupgradeFromGitHub()callsImplementation Details
parseGitStatusEntries()function parses git porcelain format status output into a Map for easier comparisongetNewlyChangedFiles()compares before/after status maps to identify files with changed stateshttps://claude.ai/code/session_01RobTdhpRAXuPkyQ8CknbWd