Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[flutter_plugin_tools] ignore flutter_plugin_tools when publishing #4110

Merged
merged 3 commits into from
Jun 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions script/tool/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.3.0+1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is another version bump necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are right, it is unnecessary. I'll revert it


- `publish-plugins` ignores `flutter_plugin_tools`, see: https://github.com/flutter/flutter/issues/85430

## 0.3.0

- Add a --build-id flag to `firebase-test-lab` instead of hard-coding the use of
Expand Down
8 changes: 8 additions & 0 deletions script/tool/lib/src/publish_plugin_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,14 @@ Safe to ignore if the package is deleted in this commit.
}

final Pubspec pubspec = Pubspec.parse(pubspecFile.readAsStringSync());

if (pubspec.name == 'flutter_plugin_tools') {
// Ignore flutter_plugin_tools package when running publishing through flutter_plugin_tools.
// TODO(cyanglaz): Make the tool also auto publish flutter_plugin_tools package.
// https://github.com/flutter/flutter/issues/85430
return _CheckNeedsReleaseResult.noRelease;
}

if (pubspec.publishTo == 'none') {
return _CheckNeedsReleaseResult.noRelease;
}
Expand Down
2 changes: 1 addition & 1 deletion script/tool/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_plugin_tools
description: Productivity utils for flutter/plugins and flutter/packages
repository: https://github.com/flutter/plugins/tree/master/script/tool
version: 0.3.0
version: 0.3.0+1

dependencies:
args: ^2.1.0
Expand Down
51 changes: 51 additions & 0 deletions script/tool/test/publish_plugin_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,57 @@ void main() {
]));
expect(processRunner.pushTagsArgs, isEmpty);
});

test('Do not release flutter_plugin_tools', () async {
const Map<String, dynamic> httpResponsePlugin1 = <String, dynamic>{
'name': 'flutter_plugin_tools',
'versions': <String>[],
};

final MockClient mockClient = MockClient((http.Request request) async {
if (request.url.pathSegments.last == 'flutter_plugin_tools.json') {
return http.Response(json.encode(httpResponsePlugin1), 200);
}
return http.Response('', 500);
});
final PublishPluginCommand command = PublishPluginCommand(packagesDir,
processRunner: processRunner,
print: (Object? message) => printedMessages.add(message.toString()),
stdinput: mockStdin,
httpClient: mockClient,
gitDir: gitDir);

commandRunner = CommandRunner<void>(
'publish_check_command',
'Test for publish-check command.',
);
commandRunner.addCommand(command);

final Directory flutterPluginTools =
createFakePlugin('flutter_plugin_tools', packagesDir);
await gitDir.runCommand(<String>['add', '-A']);
await gitDir.runCommand(<String>['commit', '-m', 'Add plugins']);
// Immediately return 0 when running `pub publish`.
processRunner.mockPublishCompleteCode = 0;
mockStdin.readLineOutput = 'y';
await commandRunner
.run(<String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']);
expect(
printedMessages,
containsAllInOrder(<String>[
'Checking local repo...',
'Local repo is ready!',
'Done!'
]));
expect(
printedMessages.contains(
'Running `pub publish ` in ${flutterPluginTools.path}...\n',
),
isFalse);
expect(processRunner.pushTagsArgs, isEmpty);
processRunner.pushTagsArgs.clear();
printedMessages.clear();
});
});
}

Expand Down