Unverified Commit 0d277223 authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

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

Fixes https://github.com/flutter/flutter/issues/128067
parent 1a098ae8
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment