Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check licenses of generated files #326

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/firehose/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.10.2-wip

- Don't check licenses of generated files in PR health workflow.

## 0.10.1

- Small fixes to the PR health checker.
Expand Down
12 changes: 10 additions & 2 deletions pkgs/firehose/lib/src/health/license.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Future<List<String>> getFilesWithoutLicenses(
if (ignoredFiles.none((glob) =>
glob.matches(path.relative(file.path, from: repositoryDir.path)))) {
var fileContents = File(file.path).readAsStringSync();
var fileContainsCopyright = fileContents.contains('// Copyright (c)');
if (!fileContainsCopyright) {
if (!fileIsGenerated(fileContents) &&
!fileContainsCopyright(fileContents)) {
print(relativePath);
return relativePath;
}
Expand All @@ -40,3 +40,11 @@ Future<List<String>> getFilesWithoutLicenses(
Done, found ${filesWithoutLicenses.length} files without license headers''');
return filesWithoutLicenses;
}

bool fileIsGenerated(String fileContents) => fileContents
mosuem marked this conversation as resolved.
Show resolved Hide resolved
.split('\n')
.takeWhile((line) => line.startsWith('//') || line.isEmpty)
.any((line) => line.toLowerCase().contains('generate'));

bool fileContainsCopyright(String fileContents) =>
fileContents.contains('// Copyright (c)');
2 changes: 1 addition & 1 deletion pkgs/firehose/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: firehose
description: A tool to automate publishing of Pub packages from GitHub actions.
version: 0.10.1
version: 0.10.2-wip
repository: https://github.com/dart-lang/ecosystem/tree/main/pkgs/firehose

environment:
Expand Down
1 change: 0 additions & 1 deletion pkgs/firehose/test_data/golden/comment_license.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
| Files |
| :--- |
|pkgs/package1/bin/package1.dart|
|pkgs/package2/lib/anotherLib.dart|
|pkgs/package5/lib/src/package5_base.dart|

All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
|pkgs/package1/bin/package1.dart|
|pkgs/package1/lib/package1.dart|
|pkgs/package1/test/package1_test.dart|
|pkgs/package2/lib/anotherLib.dart|
|pkgs/package2/lib/package2.dart|
|pkgs/package2/test/package2_test.dart|
|pkgs/package3/bin/package3.dart|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
| Files |
| :--- |
|pkgs/package1/bin/package1.dart|
|pkgs/package2/lib/anotherLib.dart|
|pkgs/package5/lib/src/package5_base.dart|

All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

| Files |
| :--- |
|pkgs/package2/lib/anotherLib.dart|
|pkgs/package5/lib/src/package5_base.dart|

All source files should start with a [license header](https://github.com/dart-lang/ecosystem/wiki/License-Header).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// SOME COMMENT
// THIS IS A GENERATED FILE

int calculateUnused() {
return 6 * 7;
}
Loading