Skip to content

Commit

Permalink
Sort licenses by body (flutter#36577)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hixie authored Oct 5, 2022
1 parent 57d2ef0 commit 6232980
Show file tree
Hide file tree
Showing 7 changed files with 50,517 additions and 50,515 deletions.
6,536 changes: 3,268 additions & 3,268 deletions ci/licenses_golden/licenses_flutter

Large diffs are not rendered by default.

6,558 changes: 3,279 additions & 3,279 deletions ci/licenses_golden/licenses_fuchsia

Large diffs are not rendered by default.

11,542 changes: 5,771 additions & 5,771 deletions ci/licenses_golden/licenses_skia

Large diffs are not rendered by default.

52,666 changes: 26,333 additions & 26,333 deletions ci/licenses_golden/licenses_third_party

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ci/licenses_golden/tool_signature
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Signature: eeb0c647625047671a862bb877890a5f
Signature: ebfee4cf8fc59213ae6efbc0c13dc6c8

23,711 changes: 11,855 additions & 11,856 deletions sky/packages/sky_engine/LICENSE

Large diffs are not rendered by default.

17 changes: 10 additions & 7 deletions tools/licenses/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ abstract class _RepositoryLicensedFile extends _RepositoryFile {
static final RegExp _readmeNamePattern = RegExp(r'\b_*(?:readme|contributing|patents)_*\b', caseSensitive: false);
static final RegExp _buildTimePattern = RegExp(r'^(?!.*gen$)(?:CMakeLists\.txt|(?:pkgdata)?Makefile(?:\.inc)?(?:\.am|\.in|)|configure(?:\.ac|\.in)?|config\.(?:sub|guess)|.+\.m4|install-sh|.+\.sh|.+\.bat|.+\.pyc?|.+\.pl|icu-configure|.+\.gypi?|.*\.gni?|.+\.mk|.+\.cmake|.+\.gradle|.+\.yaml|pubspec\.lock|\.packages|vms_make\.com|pom\.xml|\.project|source\.properties|.+\.obj|.+\.autopkg|Brewfile)$', caseSensitive: false);
static final RegExp _docsPattern = RegExp(r'^(?:INSTALL|NEWS|OWNERS|AUTHORS|ChangeLog(?:\.rst|\.[0-9]+)?|.+\.txt|.+\.md|.+\.log|.+\.css|.+\.1|doxygen\.config|Doxyfile|.+\.spec(?:\.in)?)$', caseSensitive: false);
static final RegExp _devPattern = RegExp(r'^(?:codereview\.settings|.+\.~|.+\.~[0-9]+~|\.clang-format|swift\.swiftformat|\.gitattributes|\.landmines|\.DS_Store|\.travis\.yml|\.cirrus\.yml|\.cache|\.mailmap)$', caseSensitive: false);
static final RegExp _devPattern = RegExp(r'^(?:codereview\.settings|.+\.~|.+\.~[0-9]+~|\.clang-format|swift\.swiftformat|\.gitattributes|\.landmines|\.DS_Store|\.travis\.yml|\.cirrus\.yml|\.cache|\.mailmap|CODEOWNERS|TESTOWNERS)$', caseSensitive: false);
static final RegExp _testsPattern = RegExp(r'^(?:tj(?:bench|example)test\.(?:java\.)?in|example\.c)$', caseSensitive: false);
// The ICU library has sample code that will never get linked.
static final RegExp _icuSamplesPattern = RegExp(r'.*(?:icu\/source\/samples).*$', caseSensitive: false);
Expand Down Expand Up @@ -2854,16 +2854,19 @@ Future<void> _collectLicensesForComponent(_RepositoryDirectory componentRoot, {
}

sink.writeln('UNUSED LICENSES:\n');
final List<String> unusedLicenses = licenses
final List<License> rawUnusedLicenses = licenses
.where((License license) => !license.isUsed)
.toList();
rawUnusedLicenses.sort((License a, License b) => a.toStringBody().compareTo(b.toStringBody()));
final List<String> unusedLicenses = rawUnusedLicenses
.map((License license) => license.toString())
.toList();
unusedLicenses.sort();
sink.writeln(unusedLicenses.join('\n\n'));
sink.writeln('~' * 80);

sink.writeln('USED LICENSES:\n');
final List<License> usedLicenses = licenses.where((License license) => license.isUsed).toList();
usedLicenses.sort((License a, License b) => a.toStringBody().compareTo(b.toStringBody()));
final List<String> output = usedLicenses.map((License license) => license.toString()).toList();
for (int index = 0; index < output.length; index += 1) {
// The strings we look for here are strings which we do not expect to see in
Expand Down Expand Up @@ -2907,8 +2910,6 @@ Future<void> _collectLicensesForComponent(_RepositoryDirectory componentRoot, {
throw 'Unexpected indecisiveness found in: ${usedLicenses[index].origin}';
}
}

output.sort();
sink.writeln(output.join('\n\n'));
sink.writeln('Total license count: ${licenses.length}');

Expand Down Expand Up @@ -2968,12 +2969,14 @@ Future<void> main(List<String> arguments) async {
}
progress.label = 'Dumping results...';
progress.flush();
final List<String?> output = licenses
final List<License> sortedLicenses = licenses
.where((License license) => license.isUsed)
.toList();
sortedLicenses.sort((License a, License b) => a.toStringBody().compareTo(b.toStringBody()));
final List<String?> output = sortedLicenses
.map((License license) => license.toStringFormal())
.whereNotNull()
.toList();
output.sort();
print(output.join('\n${"-" * 80}\n'));
progress.label = 'Done.';
progress.flush();
Expand Down

0 comments on commit 6232980

Please sign in to comment.