@@ -1881,20 +1881,22 @@ class _Progress {
1881
1881
}
1882
1882
}
1883
1883
1884
- final RegExp _signaturePattern = RegExp (r'^Signature: (\w+)$' , expectNoMatch: true );
1884
+ final RegExp _signaturePattern = RegExp (r'^Signature: (\w+)$' , multiLine : true , expectNoMatch: true );
1885
1885
1886
1886
/// Reads the signature from a golden file.
1887
1887
String ? _readSignature (String goldenPath) {
1888
1888
try {
1889
1889
final system.File goldenFile = system.File (goldenPath);
1890
1890
if (! goldenFile.existsSync ()) {
1891
+ system.stderr.writeln (' Could not find signature file ($goldenPath ).' );
1891
1892
return null ;
1892
1893
}
1893
1894
final String goldenSignature = goldenFile.readAsStringSync ();
1894
1895
final Match ? goldenMatch = _signaturePattern.matchAsPrefix (goldenSignature);
1895
1896
if (goldenMatch != null ) {
1896
1897
return goldenMatch.group (1 );
1897
1898
}
1899
+ system.stderr.writeln (' Signature file ($goldenPath ) did not match expected pattern.' );
1898
1900
} on system.FileSystemException {
1899
1901
system.stderr.writeln (' Failed to read signature file ($goldenPath ).' );
1900
1902
return null ;
@@ -1913,7 +1915,6 @@ void _writeSignature(String signature, system.IOSink sink) {
1913
1915
//
1914
1916
// Returns true if changes are detected.
1915
1917
Future <bool > _computeLicenseToolChanges (_RepositoryDirectory root, { required String goldenSignaturePath, required String outputSignaturePath }) async {
1916
- system.stderr.writeln ('Computing signature for license tool' );
1917
1918
final fs.Directory flutterNode = findChildDirectory (root.ioDirectory, 'flutter' )! ;
1918
1919
final fs.Directory toolsNode = findChildDirectory (flutterNode, 'tools' )! ;
1919
1920
final fs.Directory licenseNode = findChildDirectory (toolsNode, 'licenses' )! ;
@@ -1933,23 +1934,27 @@ Future<bool> _computeLicenseToolChanges(_RepositoryDirectory root, { required St
1933
1934
Future <void > _collectLicensesForComponent (_RepositoryDirectory componentRoot, {
1934
1935
required String inputGoldenPath,
1935
1936
String ? outputGoldenPath,
1936
- bool ? writeSignature,
1937
+ required bool writeSignature,
1937
1938
required bool force,
1938
1939
required bool quiet,
1939
1940
}) async {
1940
- // Check whether the golden file matches the signature of the current contents of this directory.
1941
- final String ? goldenSignature = _readSignature (inputGoldenPath);
1942
1941
final String signature = await componentRoot.signature;
1943
- if (! force && goldenSignature == signature) {
1944
- system.stderr.writeln (' Skipping this component - no change in signature' );
1945
- return ;
1942
+ if (writeSignature) {
1943
+ // Check whether the golden file matches the signature of the current contents of this directory.
1944
+ // (We only do this for components where we write the signature, since if there's no signature,
1945
+ // there's no point trying to read it...)
1946
+ final String ? goldenSignature = _readSignature (inputGoldenPath);
1947
+ if (! force && goldenSignature == signature) {
1948
+ system.stderr.writeln (' Skipping this component - no change in signature' );
1949
+ return ;
1950
+ }
1946
1951
}
1947
1952
1948
1953
final _Progress progress = _Progress (componentRoot.fileCount, quiet: quiet);
1949
1954
1950
1955
final system.File outFile = system.File (outputGoldenPath! );
1951
1956
final system.IOSink sink = outFile.openWrite ();
1952
- if (writeSignature! ) {
1957
+ if (writeSignature) {
1953
1958
_writeSignature (signature, sink);
1954
1959
}
1955
1960
0 commit comments