diff --git a/dev/conductor/core/lib/src/packages_autoroller.dart b/dev/conductor/core/lib/src/packages_autoroller.dart index b27a2bb65e..2ab002d51a 100644 --- a/dev/conductor/core/lib/src/packages_autoroller.dart +++ b/dev/conductor/core/lib/src/packages_autoroller.dart @@ -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 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([ '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 openPrs = json.decode(openPrString) as List; + // 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; diff --git a/dev/conductor/core/test/packages_autoroller_test.dart b/dev/conductor/core/test/packages_autoroller_test.dart index 9ffc6cd8d1..0b1d54d4fe 100644 --- a/dev/conductor/core/test/packages_autoroller_test.dart +++ b/dev/conductor/core/test/packages_autoroller_test.dart @@ -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