[Tool] Ignore pubspec.lock dirty checkout modifications on non-stable channels#184997
Conversation
… channels On non-stable branches like master or main, dev Dart SDK constraints are automatically written into pubspec.lock files during internal operations. This modified lock file blocks automatic upgrades. This commit filters lock files out of dirty checkout calculations when channel is not stable. Fixes flutter#178777
There was a problem hiding this comment.
Code Review
This pull request modifies the upgrade command to allow local changes to pubspec.lock files during upgrades on non-stable branches. The hasUncommittedChanges method was updated to evaluate the Flutter channel and filter git status output accordingly. Feedback suggests refining the file name matching logic to ensure it only targets pubspec.lock and not other files with similar suffixes.
| // These files are automatically updated with the active Dart SDK dev | ||
| // constraints during internal tool operations, and should not block | ||
| // the automatic upgrade workflow. | ||
| if (!trimmed.endsWith('pubspec.lock')) { |
There was a problem hiding this comment.
The check trimmed.endsWith('pubspec.lock') is slightly too permissive as it could match files like another_pubspec.lock or not_a_pubspec.lock. It is safer to check for the exact filename by ensuring it is preceded by a directory separator or a space (which separates the git status code from the path in git status -s output).
| if (!trimmed.endsWith('pubspec.lock')) { | |
| if (!trimmed.endsWith('/pubspec.lock') && !trimmed.endsWith(' pubspec.lock')) { |
On non-stable branches like master or main, dev Dart SDK constraints are automatically written into pubspec.lock files during internal operations. This modified lock file blocks automatic upgrades. This commit filters lock files out of dirty checkout calculations when channel is not stable.
Fixes #178777