Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion pkgs/firehose/lib/src/health/coverage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ class Coverage {
.where((file) => file.status != FileStatus.removed)
.where((file) => isInSomePackage(packages, file.filename))
.where((file) => isNotATest(packages, file.filename))
.where(
(file) => ignoredFiles.none((glob) => glob.matches(file.filename)))
.toList();
print('The files of interest are $filesOfInterest');

var baseRepository = Repository(base);
var basePackages = baseRepository.locatePackages(ignore: ignoredFiles);
var basePackages = baseRepository.locatePackages(ignore: ignoredPackages);
print('Found packages $basePackages at $base');

var changedPackages = packages
Expand Down
14 changes: 12 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, file.path) &&
!fileContainsCopyright(fileContents)) {
print(relativePath);
return relativePath;
}
Expand All @@ -40,3 +40,13 @@ Future<List<String>> getFilesWithoutLicenses(
Done, found ${filesWithoutLicenses.length} files without license headers''');
return filesWithoutLicenses;
}

bool fileIsGenerated(String fileContents, String path) =>
path.endsWith('g.dart') ||
Copy link
Member

@devoncarew devoncarew Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor nit; ==> '.g.dart'.

fileContents
.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