classifyFile method
Classifies a single file path into a PatchChangeCategory.
Implementation
PatchChangeCategory classifyFile(String filePath) {
final normalized = filePath.replaceAll('\\', '/').toLowerCase();
// 1. Native Android
if (normalized.startsWith('android/') ||
normalized == 'build.gradle' ||
normalized == 'settings.gradle' ||
normalized.endsWith('.gradle') ||
normalized.endsWith('.java') ||
normalized.endsWith('.kt') ||
normalized.endsWith('.aar')) {
return PatchChangeCategory.nativeAndroid;
}
// 2. Native iOS
if (normalized.startsWith('ios/') ||
normalized == 'podfile' ||
normalized == 'podfile.lock' ||
normalized.endsWith('.podspec') ||
normalized.endsWith('.swift') ||
normalized.endsWith('.m') ||
normalized.endsWith('.h') ||
normalized.contains('.xcodeproj/') ||
normalized.contains('.xcworkspace/')) {
return PatchChangeCategory.nativeIos;
}
// 3. Dependencies
if (normalized == 'pubspec.yaml' || normalized == 'pubspec.lock') {
return PatchChangeCategory.dependencies;
}
// 4. Assets
if (normalized.startsWith('assets/') ||
normalized.startsWith('images/') ||
normalized.startsWith('fonts/')) {
return PatchChangeCategory.assets;
}
// 5. Configuration & Metadata
if (normalized == 'analysis_options.yaml' ||
normalized == 'l10n.yaml' ||
normalized == '.gitignore' ||
normalized == 'build.yaml') {
return PatchChangeCategory.configuration;
}
// 6. Generated Dart Code
if (normalized.endsWith('.g.dart') ||
normalized.endsWith('.freezed.dart') ||
normalized.endsWith('.gen.dart') ||
normalized.endsWith('.gr.dart')) {
return PatchChangeCategory.generatedDart;
}
// 7. Dart Source Code
if (normalized.endsWith('.dart') &&
(normalized.startsWith('lib/') || normalized.startsWith('bin/'))) {
return PatchChangeCategory.dart;
}
// 8. Unknown / Unclassified
return PatchChangeCategory.unknown;
}