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

Continue with labeling after error with issue transfer #293

Merged
merged 4 commits into from
Sep 2, 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
71 changes: 52 additions & 19 deletions .github/workflows/dart.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 31 additions & 14 deletions pkgs/repo_manage/lib/issue_transfer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// 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 'dart:io';

import 'package:collection/collection.dart';
import 'package:github/github.dart';
import 'package:graphql/client.dart';
Expand Down Expand Up @@ -94,16 +96,21 @@ class TransferIssuesCommand extends ReportCommand {
);

print('Transferred ${issues.length} issues');

if (labelName != null) {
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],
);
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],
);
}
}
}
}
Expand Down Expand Up @@ -194,7 +201,12 @@ class TransferIssuesCommand extends ReportCommand {
repositoryId,
applyChanges,
);
allIssueIds.addAll(transferredIssues);
if (transferredIssues.$2 != null) {
stderr.writeln('Failed to transfer issues.');
stderr.writeln(transferredIssues.$2);
return allIssueIds;
}
allIssueIds.addAll(transferredIssues.$1);
await Future<void>.delayed(const Duration(seconds: 1));
}

Expand All @@ -209,7 +221,7 @@ class TransferIssuesCommand extends ReportCommand {
}
}

Future<List<int>> _transferMutation(
Future<(List<int>, Exception?)> _transferMutation(
List<String> issueIds,
String repositoryId,
bool applyChanges,
Expand Down Expand Up @@ -239,10 +251,15 @@ class TransferIssuesCommand extends ReportCommand {
.toList();
},
));
if (result.hasException) throw result.exception!;
return result.parsedData ?? [];
return (result.parsedData ?? [], result.exception);
} else {
return [];
return (<int>[], null);
}
}

bool getInput(String question) {
print(question);
final line = stdin.readLineSync()?.toLowerCase();
return line == 'y' || line == 'yes';
}
}
2 changes: 1 addition & 1 deletion pkgs/repo_manage/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Miscellaneous issue, repo, and PR query tools.
publish_to: none

environment:
sdk: ^3.1.0
sdk: ^3.3.0

dependencies:
args: ^2.4.0
Expand Down
18 changes: 11 additions & 7 deletions tool/ci.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/bin/bash
# Created with package:mono_repo v6.6.2
# Created with package:mono_repo v6.5.1

# Support built in commands on windows out of the box.

# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter")
# then "flutter pub" is called instead of "dart pub".
# then "flutter" is called instead of "pub".
# This assumes that the Flutter SDK has been installed in a previous step.
function pub() {
if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then
Expand All @@ -13,13 +12,18 @@ function pub() {
command dart pub "$@"
fi
}

# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter")
# then "flutter" is called instead of "pub".
# This assumes that the Flutter SDK has been installed in a previous step.
function format() {
command dart format "$@"
if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then
command flutter format "$@"
else
command dart format "$@"
fi
}

# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter")
# then "flutter analyze" is called instead of "dart analyze".
# then "flutter" is called instead of "pub".
# This assumes that the Flutter SDK has been installed in a previous step.
function analyze() {
if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then
Expand Down
Loading