Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
merge master
  • Loading branch information
Chris Yang committed Apr 27, 2021
commit 6055c912c77bc8bb0fafe8b59a5cf24d4948b1cb
73 changes: 37 additions & 36 deletions script/tool/lib/src/publish_plugin_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class PublishPluginCommand extends PluginCommand {
await baseGitDir.runCommand(<String>['tag', '--sort=-committerdate']);
final List<String> existingTags = (existingTagsResult.stdout as String)
.split('\n')
..removeWhere((element) => element.isEmpty);
..removeWhere((String element) => element.isEmpty);

final List<String> packagesReleased = <String>[];
final List<String> packagesFailed = <String>[];
Expand Down Expand Up @@ -323,18 +323,19 @@ Safe to ignore if the package is deleted in this commit.
}) async {
final String tag = _getTag(packageDir);
_print('Tagging release $tag...');
try {
if (!(argResults[_dryRunFlag] as bool)) {
await processRunner.runAndExitOnError(
'git',
<String>['tag', tag],
workingDir: packageDir,
);
if (!(argResults[_dryRunFlag] as bool)) {
final io.ProcessResult result = await processRunner.run(
'git',
<String>['tag', tag],
workingDir: packageDir,
exitOnError: false,
logOnError: true,
);
if (result.exitCode != 0) {
return false;
}
} on ToolExit catch (e) {
_print(e);
return false;
}

if (!shouldPushTag) {
return true;
}
Expand Down Expand Up @@ -372,20 +373,14 @@ Safe to ignore if the package is deleted in this commit.
}

Future<bool> _checkGitStatus(Directory packageDir) async {
io.ProcessResult statusResult;
try {
statusResult = await processRunner.runAndExitOnError(
'git',
<String>[
'status',
'--porcelain',
'--ignored',
packageDir.absolute.path
],
workingDir: packageDir,
);
} on ToolExit catch (e) {
_print(e);
final io.ProcessResult statusResult = await processRunner.run(
'git',
<String>['status', '--porcelain', '--ignored', packageDir.absolute.path],
workingDir: packageDir,
logOnError: true,
exitOnError: false,
);
if (statusResult.exitCode != 0) {
return false;
}

Expand All @@ -400,9 +395,13 @@ Safe to ignore if the package is deleted in this commit.
}

Future<String> _verifyRemote(String remote) async {
final io.ProcessResult remoteInfo = await processRunner.runAndExitOnError(
'git', <String>['remote', 'get-url', remote],
workingDir: packagesDir);
final io.ProcessResult remoteInfo = await processRunner.run(
'git',
<String>['remote', 'get-url', remote],
workingDir: packagesDir,
exitOnError: true,
logOnError: true,
);
return remoteInfo.stdout as String;
}

Expand Down Expand Up @@ -462,15 +461,17 @@ Safe to ignore if the package is deleted in this commit.
_print('Tag push canceled.');
return false;
}
try {
if (!(argResults[_dryRunFlag] as bool)) {
await processRunner.runAndExitOnError(
'git', <String>['push', remote, tag],
workingDir: packagesDir);
if (!(argResults[_dryRunFlag] as bool)) {
final io.ProcessResult result = await processRunner.run(
'git',
<String>['push', remote, tag],
workingDir: packagesDir,
exitOnError: false,
logOnError: true,
);
if (result.exitCode != 0) {
return false;
}
} on ToolExit catch (e) {
_print(e);
return false;
}
return true;
}
Expand Down
23 changes: 16 additions & 7 deletions script/tool/test/publish_plugin_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -582,14 +582,14 @@ void main() {
final List<String> plugin1Pubspec =
pluginDir1.childFile('pubspec.yaml').readAsLinesSync();
plugin1Pubspec[plugin1Pubspec.indexWhere(
(element) => element.contains('version:'))] = 'version: 0.0.2';
(String element) => element.contains('version:'))] = 'version: 0.0.2';
pluginDir1
.childFile('pubspec.yaml')
.writeAsStringSync(plugin1Pubspec.join('\n'));
final List<String> plugin2Pubspec =
pluginDir2.childFile('pubspec.yaml').readAsLinesSync();
plugin2Pubspec[plugin2Pubspec.indexWhere(
(element) => element.contains('version:'))] = 'version: 0.0.2';
(String element) => element.contains('version:'))] = 'version: 0.0.2';
pluginDir2
.childFile('pubspec.yaml')
.writeAsStringSync(plugin2Pubspec.join('\n'));
Expand Down Expand Up @@ -673,7 +673,7 @@ void main() {
final List<String> plugin1Pubspec =
pluginDir1.childFile('pubspec.yaml').readAsLinesSync();
plugin1Pubspec[plugin1Pubspec.indexWhere(
(element) => element.contains('version:'))] = 'version: 0.0.2';
(String element) => element.contains('version:'))] = 'version: 0.0.2';
pluginDir1
.childFile('pubspec.yaml')
.writeAsStringSync(plugin1Pubspec.join('\n'));
Expand Down Expand Up @@ -761,14 +761,14 @@ void main() {
final List<String> plugin1Pubspec =
pluginDir1.childFile('pubspec.yaml').readAsLinesSync();
plugin1Pubspec[plugin1Pubspec.indexWhere(
(element) => element.contains('version:'))] = 'version: 0.0.1';
(String element) => element.contains('version:'))] = 'version: 0.0.1';
pluginDir1
.childFile('pubspec.yaml')
.writeAsStringSync(plugin1Pubspec.join('\n'));
final List<String> plugin2Pubspec =
pluginDir2.childFile('pubspec.yaml').readAsLinesSync();
plugin2Pubspec[plugin2Pubspec.indexWhere(
(element) => element.contains('version:'))] = 'version: 0.0.1';
(String element) => element.contains('version:'))] = 'version: 0.0.1';
pluginDir2
.childFile('pubspec.yaml')
.writeAsStringSync(plugin2Pubspec.join('\n'));
Expand Down Expand Up @@ -916,7 +916,7 @@ class MockStdin extends Mock implements io.Stdin {
//
// Create a new controller every time so this Stdin could be listened to multiple times.
_controller = StreamController<List<int>>();
mockUserInputs.forEach((List<int> element) => _controller.add(element));
mockUserInputs.forEach(_addUserInputsToSteam);
return _controller.stream.transform(streamTransformer);
}

Expand All @@ -932,6 +932,15 @@ class MockStdin extends Mock implements io.Stdin {
{Encoding encoding = io.systemEncoding,
bool retainNewlines = false}) =>
readLineOutput;

void _addUserInputsToSteam(List<int> input) => _controller.add(input);
}

class MockProcessResult extends Mock implements io.ProcessResult {}
class MockProcessResult extends Mock implements io.ProcessResult {
MockProcessResult({int exitCode = 0}) : _exitCode = exitCode;

final int _exitCode;

@override
int get exitCode => _exitCode;
}
You are viewing a condensed version of this merge commit. You can view the full changes here.