packageHasChanges function
Checks if a package directory has changes between two git refs
Implementation
Future<bool> packageHasChanges(
String packagePath,
String baseRef,
String newRef,
Directory gitRoot,
) async {
try {
// Use git diff to check if any files in the package directory changed
final result = await Process.run(
'git',
[
'diff',
'--name-only',
'$baseRef..$newRef',
'--',
packagePath,
],
workingDirectory: gitRoot.path,
);
if (result.exitCode != 0) {
logger.warn('Git diff failed for package $packagePath: ${result.stderr}');
// If diff fails, assume package has changes to be safe
return true;
}
final changedFiles = result.stdout.toString().trim();
return changedFiles.isNotEmpty;
} catch (e) {
logger.warn('Error checking changes for package $packagePath: $e');
// If check fails, assume package has changes to be safe
return true;
}
}