Skip to content

Conversation

gspencergoog
Copy link
Collaborator

@gspencergoog gspencergoog commented Sep 18, 2025

Description

This pull request refactors the fix_copyright tool to align its file discovery mechanism with Git's tracking capabilities. By switching from a file system traversal approach to leveraging git ls-files, the tool now precisely targets only those files actively managed by the repository, preventing unintended modifications to untracked or ignored content. This change simplifies the tool's logic and enhances its reliability within a Git-managed project.

Highlights

  • File Discovery Logic: The fix_copyright script now exclusively uses git ls-files to identify files for copyright checks, ensuring only Git-tracked files are processed.
  • Submodule Handling Removal: The previous logic for detecting and skipping Git submodules has been removed, as git ls-files inherently handles the scope of tracked files.
  • Test Suite Refinement: The test suite for fix_copyright has been updated to reflect the new git ls-files dependency, including the introduction of a helper function mockGitLsFiles to streamline test setup.
Changelog
  • packages/spikes/gulf_genkit_eval/src/index.ts
    • Updated copyright header to remove "All rights reserved.".
  • packages/spikes/gulf_genkit_eval/src/models.ts
    • Updated copyright header to remove "All rights reserved.".
  • packages/spikes/gulf_genkit_eval/src/prompts.ts
    • Updated copyright header to remove "All rights reserved.".
  • packages/spikes/gulf_genkit_eval/src/validator.ts
    • Updated copyright header to remove "All rights reserved.".
  • tool/fix_copyright/lib/src/fix_copyright.dart
    • Replaced file system traversal and submodule detection with git ls-files for file discovery.
    • Added error handling for when the tool is not run in a Git repository or git ls-files fails.
    • Removed submodulePaths variable and related logic.
  • tool/fix_copyright/test/fix_copyright_test.dart
    • Introduced mockGitLsFiles helper function to simplify mocking git ls-files command in tests.
    • Updated existing tests to use the new mockGitLsFiles helper.
    • Removed tests specifically related to submodule handling, as that logic is no longer present.
    • Adjusted expected error messages in tests to reflect the new Git repository check.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the fix_copyright tool to use git ls-files for discovering files, which is a great simplification over the previous manual directory traversal logic. This makes the tool's behavior more aligned with operating only on files tracked by git. The changes look good, and I've added a couple of suggestions to improve the test suite's maintainability and coverage of new failure paths, in accordance with the project's style guide which emphasizes testing.

@flutter flutter deleted a comment from gemini-code-assist bot Sep 18, 2025
Copy link
Collaborator

@jacobsimionato jacobsimionato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great!!

@jacobsimionato
Copy link
Collaborator

Thank you for taking care of this hassle so we don't have to! I actually didn't even realise git submodules were a thing until now 😬

@jacobsimionato jacobsimionato merged commit 0b5015a into flutter:main Sep 19, 2025
13 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