diff --git a/pkgs/firehose/lib/src/health/license.dart b/pkgs/firehose/lib/src/health/license.dart index ae39d2e5..c58b502f 100644 --- a/pkgs/firehose/lib/src/health/license.dart +++ b/pkgs/firehose/lib/src/health/license.dart @@ -42,7 +42,7 @@ Done, found ${filesWithoutLicenses.length} files without license headers'''); } bool fileIsGenerated(String fileContents, String path) => - path.endsWith('g.dart') || + path.endsWith('.g.dart') || fileContents .split('\n') .takeWhile((line) => line.startsWith('//') || line.isEmpty) diff --git a/pkgs/repo_manage/lib/issue_transfer.dart b/pkgs/repo_manage/lib/issue_transfer.dart index fa624a7f..5c2f06d8 100644 --- a/pkgs/repo_manage/lib/issue_transfer.dart +++ b/pkgs/repo_manage/lib/issue_transfer.dart @@ -39,6 +39,7 @@ class TransferIssuesCommand extends ReportCommand { 'add-label', help: 'Add a label to all transferred issues.', valueHelp: 'package:foo', + mandatory: true, ); } @@ -54,7 +55,7 @@ class TransferIssuesCommand extends ReportCommand { var sourceRepo = parsedArgs.option('source-repo')!; var targetRepo = parsedArgs.option('target-repo')!; - var labelName = argResults!['add-label'] as String?; + var labelName = argResults!['add-label'] as String; if (!applyChanges) { print('This is a dry run, no issues will be transferred!'); @@ -70,15 +71,14 @@ class TransferIssuesCommand extends ReportCommand { Future transferAndLabelIssues( RepositorySlug sourceRepo, - RepositorySlug targetRepo, [ - String? labelName, + RepositorySlug targetRepo, + String labelName, [ bool applyChanges = false, ]) async { - if (labelName != null) { - print('Create label $labelName'); - if (applyChanges) { - await reportRunner.github.issues.createLabel(targetRepo, labelName); - } + print('Create label $labelName in source and target repo'); + if (applyChanges) { + await reportRunner.github.issues.createLabel(targetRepo, labelName); + await reportRunner.github.issues.createLabel(sourceRepo, labelName); } var issues = await transferIssues( @@ -90,28 +90,11 @@ class TransferIssuesCommand extends ReportCommand { print('Transferred ${issues.length} issues'); - if (labelName != null) { - var label = - getInput('Label the transferred issues with $labelName? (y/N)'); - if (label) { - print('Adding label $labelName to all transferred issues'); - for (var issueNumber in issues) { - print('Add to issue $issueNumber'); - if (applyChanges) { - await reportRunner.github.issues.addLabelsToIssue( - targetRepo, - issueNumber, - [labelName], - ); - } - } - } - } - return 0; } - Future> getIssueIds(RepositorySlug slug) async { + Future> getIssueIds( + RepositorySlug slug) async { final queryString = '''query { repository(owner:"${slug.owner}", name:"${slug.name}") { issues(last:100) { @@ -134,7 +117,8 @@ class TransferIssuesCommand extends ReportCommand { var nodes = issues['nodes'] as List; return nodes .map((node) => node as Map) - .map((node) => node['id'] as String) + .map((node) => + (id: node['id'] as String, number: node['number'] as int)) .toList(); }, )); @@ -163,7 +147,7 @@ class TransferIssuesCommand extends ReportCommand { Future> transferIssues( RepositorySlug sourceRepo, RepositorySlug targetRepo, - String? issueLabel, + String issueLabel, bool applyChanges, ) async { var repositoryId = await getRepositoryId(targetRepo); @@ -183,8 +167,20 @@ class TransferIssuesCommand extends ReportCommand { for (var issueIdChunk in issueIds.slices(10)) { print('Transferring a chunk of ${issueIdChunk.length} issues'); + print('Adding label $issueLabel to all issues in chunk'); + for (var issueNumber in issueIdChunk) { + print('Add to issue $issueNumber'); + if (applyChanges) { + await reportRunner.github.issues.addLabelsToIssue( + sourceRepo, + issueNumber.number, + [issueLabel], + ); + } + } + await Future.delayed(const Duration(milliseconds: 500)); var transferredIssues = await _transferMutation( - issueIdChunk, + issueIdChunk.map((issue) => issue.id).toList(), repositoryId, applyChanges, ); @@ -194,7 +190,7 @@ class TransferIssuesCommand extends ReportCommand { return allIssueIds; } allIssueIds.addAll(transferredIssues.$1); - await Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(milliseconds: 500)); } if (!applyChanges) { diff --git a/pkgs/trebuchet/bin/trebuchet.dart b/pkgs/trebuchet/bin/trebuchet.dart index 7cd0a771..548777c2 100644 --- a/pkgs/trebuchet/bin/trebuchet.dart +++ b/pkgs/trebuchet/bin/trebuchet.dart @@ -129,8 +129,12 @@ class Trebuchet { print('Start moving package'); - print('Rename to `pkgs/`'); - await filterRepo(['--path-rename', ':pkgs/$input/']); + print('Checkout correct branch at target repo'); + await runProcess('git', ['checkout', targetBranchName]); + + final prefix = 'pkgs'; + print('Rename to `$prefix/`'); + await filterRepo(['--path-rename', ':$prefix/$input/']); print('Prefix tags'); await filterRepo(['--tag-rename', ':$input-']); @@ -169,12 +173,12 @@ class Trebuchet { Pubspec? pubspec; if (!dryRun) { final pubspecFile = - File(p.join(targetPath, 'pkgs', input, 'pubspec.yaml')); + File(p.join(targetPath, prefix, input, 'pubspec.yaml')); final pubspecContents = await pubspecFile.readAsString(); pubspec = Pubspec.parse(pubspecContents); final newPubspecContents = pubspecContents.replaceFirst( 'repository: https://github.com/dart-lang/$input', - 'repository: https://github.com/dart-lang/$target/tree/$targetBranchName/pkgs/$input', + 'repository: https://github.com/dart-lang/$target/tree/$targetBranchName/$prefix/$input', ); await pubspecFile.writeAsString(newPubspecContents); } @@ -196,7 +200,7 @@ labels: "package:$input" print('Remove CONTRIBUTING.md'); if (!dryRun) { final contributingFile = - File(p.join(targetPath, 'pkgs', input, 'CONTRIBUTING.md')); + File(p.join(targetPath, prefix, input, 'CONTRIBUTING.md')); if (await contributingFile.exists()) await contributingFile.delete(); } @@ -229,7 +233,7 @@ Add a line to the changelog: ''' Add the package to the top-level readme of the monorepo: ``` -| [$input](pkgs/$input/) | ${pubspec?.description ?? ''} | [![pub package](https://img.shields.io/pub/v/$input.svg)](https://pub.dev/packages/$input) | +| [$input]($prefix/$input/) | ${pubspec?.description ?? ''} | [![package issues](https://img.shields.io/badge/issues-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3A$input) | [![pub package](https://img.shields.io/pub/v/$input.svg)](https://pub.dev/packages/$input) | ``` ''', "**Important!** Merge the PR with 'Create a merge commit' (enabling then disabling the `Allow merge commits` admin setting)", @@ -239,12 +243,14 @@ Add the following text to https://github.com/dart-lang/$input/:' ``` > [!IMPORTANT] -> This repo has moved to https://github.com/dart-lang/$target/tree/$targetBranchName/pkgs/$input +> This repo has moved to https://github.com/dart-lang/$target/tree/$targetBranchName/$prefix/$input ``` ''', 'Publish using the autopublish workflow', """Push tags to GitHub using -```git tag --list '$input*' | xargs git push origin``` +``` +git tag --list '$input*' | xargs git push origin +``` """, ''' Close open PRs in dart-lang/$input with the following message: @@ -254,7 +260,9 @@ Closing as the [dart-lang/$input](https://github.com/dart-lang/$input) repositor ``` ''', '''Transfer issues by running -```dart run pkgs/repo_manage/bin/report.dart transfer-issues --source-repo dart-lang/$input --target-repo dart-lang/$target --add-label package:$input --apply-changes``` +``` +dart run pkgs/repo_manage/bin/report.dart transfer-issues --source-repo dart-lang/$input --target-repo dart-lang/$target --add-label package:$input --apply-changes +``` ''', 'Archive https://github.com/dart-lang/$input/', ];