diff --git a/ci/licenses_golden/tool_signature b/ci/licenses_golden/tool_signature index 16527fe6563b4..65fb31c25c8f5 100644 --- a/ci/licenses_golden/tool_signature +++ b/ci/licenses_golden/tool_signature @@ -1,2 +1,2 @@ -Signature: cb8556d451f3040815fe5ee661d5dbad +Signature: e2ee4730163d78d2bccaf0b4ceb5cbcf diff --git a/tools/licenses/lib/filesystem.dart b/tools/licenses/lib/filesystem.dart index 071ad10b578db..ba1d17ce19472 100644 --- a/tools/licenses/lib/filesystem.dart +++ b/tools/licenses/lib/filesystem.dart @@ -70,20 +70,21 @@ bool isMultiLicenseNotice(Reader reader) { } FileType identifyFile(String name, Reader reader) { + final List pathComponents = path.split(name); List? bytes; - if ((path.split(name).reversed.take(6).toList().reversed.join('/') == 'third_party/icu/source/extra/uconv/README') || // This specific ICU README isn't in UTF-8. - (path.split(name).reversed.take(6).toList().reversed.join('/') == 'third_party/icu/source/samples/uresb/sr.txt') || // This specific sample contains non-UTF-8 data (unlike other sr.txt files). - (path.split(name).reversed.take(2).toList().reversed.join('/') == 'builds/detect.mk') || // This specific freetype sample contains non-UTF-8 data (unlike other .mk files). - (path.split(name).reversed.take(3).toList().reversed.join('/') == 'third_party/cares/cares.rc')) { + if ((pathComponents.reversed.take(6).toList().reversed.join('/') == 'third_party/icu/source/extra/uconv/README') || // This specific ICU README isn't in UTF-8. + (pathComponents.reversed.take(6).toList().reversed.join('/') == 'third_party/icu/source/samples/uresb/sr.txt') || // This specific sample contains non-UTF-8 data (unlike other sr.txt files). + (pathComponents.reversed.take(2).toList().reversed.join('/') == 'builds/detect.mk') || // This specific freetype sample contains non-UTF-8 data (unlike other .mk files). + (pathComponents.reversed.take(3).toList().reversed.join('/') == 'third_party/cares/cares.rc')) { return FileType.latin1Text; } - if (path.split(name).reversed.take(6).toList().reversed.join('/') == 'dart/runtime/tests/vm/dart/bad_snapshot') { // Not any particular format + if (pathComponents.reversed.take(6).toList().reversed.join('/') == 'dart/runtime/tests/vm/dart/bad_snapshot') { // Not any particular format return FileType.binary; } - if (path.split(name).reversed.take(9).toList().reversed.join('/') == 'fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle_disposition.dart' || // has bogus but benign "authors" reference, reported to jamesr@ - path.split(name).reversed.take(6).toList().reversed.join('/') == 'third_party/angle/src/common/fuchsia_egl/fuchsia_egl.c' || // has bogus but benign "authors" reference, reported to author and legal team - path.split(name).reversed.take(6).toList().reversed.join('/') == 'third_party/angle/src/common/fuchsia_egl/fuchsia_egl.h' || // has bogus but benign "authors" reference, reported to author and legal team - path.split(name).reversed.take(6).toList().reversed.join('/') == 'third_party/angle/src/common/fuchsia_egl/fuchsia_egl_backend.h') { // has bogus but benign "authors" reference, reported to author and legal team + if (pathComponents.reversed.take(9).toList().reversed.join('/') == 'fuchsia/sdk/linux/dart/zircon/lib/src/fakes/handle_disposition.dart' || // has bogus but benign "authors" reference, reported to jamesr@ + pathComponents.reversed.take(6).toList().reversed.join('/') == 'third_party/angle/src/common/fuchsia_egl/fuchsia_egl.c' || // has bogus but benign "authors" reference, reported to author and legal team + pathComponents.reversed.take(6).toList().reversed.join('/') == 'third_party/angle/src/common/fuchsia_egl/fuchsia_egl.h' || // has bogus but benign "authors" reference, reported to author and legal team + pathComponents.reversed.take(6).toList().reversed.join('/') == 'third_party/angle/src/common/fuchsia_egl/fuchsia_egl_backend.h') { // has bogus but benign "authors" reference, reported to author and legal team return FileType.binary; } final String base = path.basename(name); @@ -93,7 +94,7 @@ FileType identifyFile(String name, Reader reader) { return FileType.notPartOfBuild; } // The ._* files in Mac OS X archives that gives icons and stuff } - if (path.split(name).contains('cairo')) { + if (pathComponents.contains('cairo')) { bytes ??= reader(); // "Copyright " if (hasSubsequence(bytes, [0x43, 0x6f, 0x70, 0x79, 0x72, 0x69, 0x67, 0x68, 0x74, 0x20, 0xA9, 0x20], kMaxSize)) { @@ -241,6 +242,7 @@ FileType identifyFile(String name, Reader reader) { case '.icc': return FileType.binary; // Color profile case '.swp': return FileType.binary; // Vim swap file case '.bfbs': return FileType.binary; // Flatbuffers Binary Schema + case '.rom': return FileType.binary; // Archives case '.zip': return FileType.zip; // ZIP case '.tar': return FileType.tar; // Tar