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

Transfer issues in package:trebuchet #291

Merged
merged 3 commits into from
Aug 28, 2024
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
18 changes: 12 additions & 6 deletions pkgs/repo_manage/lib/issue_transfer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:collection/collection.dart';
import 'package:github/github.dart';
import 'package:graphql/client.dart';

Expand Down Expand Up @@ -185,13 +186,18 @@ class TransferIssuesCommand extends ReportCommand {
}
print('Transfer ${issueIds.length} issues from $sourceRepo to $targetRepo'
' with id $repositoryId');
var transferredIssues = await _transferMutation(
issueIds,
repositoryId,
applyChanges,
);

allIssueIds.addAll(transferredIssues);
for (var issueIdChunk in issueIds.slices(10)) {
print('Transferring a chunk of ${issueIdChunk.length} issues');
var transferredIssues = await _transferMutation(
issueIdChunk,
repositoryId,
applyChanges,
);
allIssueIds.addAll(transferredIssues);
await Future<void>.delayed(const Duration(seconds: 1));
}

if (!applyChanges) {
// Return mock list of indices to allow user to see how downstream
// methods would continue.
Expand Down
6 changes: 4 additions & 2 deletions pkgs/trebuchet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ This is a tool to move existing packages into monorepos.
```bash
dart run bin/trebuchet.dart \
--input-name coverage \
--branch-name master \
--branch-name master \
--input-path ~/projects/coverage/ \
--target tools \
--target-path ~/projects/tools/ \
--git-filter-repo ~/tools/git-filter-repo
--git-filter-repo ~/tools/git-filter-repo \
--dry-run
```

This basically executes the instructions at https://github.com/dart-lang/ecosystem/wiki/Merging-existing-repos-into-a-monorepo
23 changes: 17 additions & 6 deletions pkgs/trebuchet/bin/trebuchet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Future<void> main(List<String> arguments) async {
'input-path',
help: 'Path to the package which should be transferred to a mono-repo',
)
..addOption(
'target',
help: 'Name of the mono-repo',
)
..addOption(
'target-path',
help: 'Path to the mono-repo',
Expand All @@ -42,11 +46,12 @@ Future<void> main(List<String> arguments) async {
negatable: false,
);

String? input;
String? inputPath;
String? targetPath;
String? branchName;
String? gitFilterRepo;
String input;
String inputPath;
String target;
String targetPath;
String branchName;
String gitFilterRepo;
bool dryRun;
try {
final parsed = argParser.parse(arguments);
Expand All @@ -57,6 +62,7 @@ Future<void> main(List<String> arguments) async {

input = parsed.option('input-name')!;
inputPath = parsed.option('input-path')!;
target = parsed.option('target')!;
targetPath = parsed.option('target-path')!;
branchName = parsed.option('branch-name')!;
gitFilterRepo = parsed.option('git-filter-repo')!;
Expand All @@ -71,6 +77,7 @@ Future<void> main(List<String> arguments) async {
final trebuchet = Trebuchet(
input: input,
inputPath: inputPath,
target: target,
targetPath: targetPath,
branchName: branchName,
gitFilterRepo: gitFilterRepo,
Expand All @@ -83,6 +90,7 @@ Future<void> main(List<String> arguments) async {
class Trebuchet {
final String input;
final String inputPath;
final String target;
final String targetPath;
final String branchName;
final String gitFilterRepo;
Expand All @@ -91,6 +99,7 @@ class Trebuchet {
Trebuchet({
required this.input,
required this.inputPath,
required this.target,
required this.targetPath,
required this.branchName,
required this.gitFilterRepo,
Expand Down Expand Up @@ -162,6 +171,7 @@ ${shouldPush ? '' : '- Run `git push --set-upstream origin merge-$input-package`
- Disable squash-only in GitHub settings, and merge with a fast forward merge to the main branch, enable squash-only in GitHub settings.
- Push tags to github using `git tag --list '$input*' | xargs git push origin`
- Follow up with a PR adding links to the top-level readme table.
- 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`
- Add a commit to https://github.com/dart-lang/$input/ with it's readme pointing to the monorepo.
- Update the auto-publishing settings on pub.dev/packages/$input.
- Archive https://github.com/dart-lang/$input/.
Expand All @@ -178,11 +188,12 @@ ${shouldPush ? '' : '- Run `git push --set-upstream origin merge-$input-package`
String executable,
List<String> arguments, {
bool inTarget = true,
bool overrideDryRun = false,
}) async {
final workingDirectory = inTarget ? targetPath : inputPath;
print('----------');
print('Running `$executable $arguments` in $workingDirectory');
if (!dryRun) {
if (!dryRun || overrideDryRun) {
final processResult = await Process.run(
executable,
arguments,
Expand Down