migrate the package_autoroller from querying by label to title (#128066)

Fixes https://github.com/flutter/flutter/issues/128067
This commit is contained in:
Christopher Fujino 2023-06-01 15:16:50 -07:00 committed by GitHub
parent 1a098ae8eb
commit 0d2772238e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 14 deletions

View File

@ -50,9 +50,11 @@ class PackageAutoroller {
static const String hostname = 'github.com';
static const String prBody = '''
This PR was generated by `flutter update-packages --force-upgrade`.
''';
String get prBody {
return '''
This PR was generated by the automated
[Pub packages autoroller](https://github.com/flutter/flutter/blob/main/dev/conductor/core/bin/packages_autoroller.dart).''';
}
/// Name of the feature branch to be opened on against the mirror repo.
///
@ -166,12 +168,13 @@ This PR was generated by `flutter update-packages --force-upgrade`.
);
}
static const String _prTitle = 'Roll pub packages';
/// Create a pull request on GitHub.
///
/// Depends on the gh cli tool.
Future<void> createPr({
required io.Directory repository,
String title = 'Roll pub packages',
String body = 'This PR was generated by `flutter update-packages --force-upgrade`.',
String base = FrameworkRepository.defaultBranch,
bool draft = false,
@ -185,7 +188,7 @@ This PR was generated by `flutter update-packages --force-upgrade`.
'pr',
'create',
'--title',
title.trim(),
_prTitle,
'--body',
body.trim(),
'--head',
@ -257,15 +260,19 @@ This PR was generated by `flutter update-packages --force-upgrade`.
final String openPrString = await cli(<String>[
'pr',
'list',
'--author',
githubUsername,
'--repo',
'flutter/flutter',
'--state',
'open',
// We are only interested in pub rolls, not devicelab flaky PRs
'--label',
'tool',
'--search',
_prTitle,
// Return structured JSON with the PR numbers of open PRs
'--json',
'number',
@ -274,6 +281,7 @@ This PR was generated by `flutter update-packages --force-upgrade`.
// This will be an array of objects, one for each open PR.
final List<Object?> openPrs = json.decode(openPrString) as List<Object?>;
// We are only interested in pub rolls, not devicelab flaky PRs
if (openPrs.isNotEmpty) {
log('$githubUsername already has open tool PRs:\n$openPrs');
return true;

View File

@ -204,8 +204,8 @@ void main() {
'flutter/flutter',
'--state',
'open',
'--label',
'tool',
'--search',
'Roll pub packages',
'--json',
'number',
// Non empty array means there are open PRs by the bot with the tool label
@ -244,8 +244,8 @@ void main() {
'flutter/flutter',
'--state',
'open',
'--label',
'tool',
'--search',
'Roll pub packages',
'--json',
'number',
// Returns empty array, as there are no other open roll PRs from the bot
@ -340,8 +340,8 @@ void main() {
'flutter/flutter',
'--state',
'open',
'--label',
'tool',
'--search',
'Roll pub packages',
'--json',
'number',
// Returns empty array, as there are no other open roll PRs from the bot