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

Commit e2c3a8e

Browse files
author
Chris Yang
committed
review
1 parent f1314f6 commit e2c3a8e

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

.cirrus.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,17 @@ task:
2222
matrix:
2323
- name: plugin_tools_tests
2424
script:
25-
- cd script/tool
26-
- pub get
2725
- CIRRUS_BUILD_ID=null pub run test
2826
- name: publishable
2927
script:
28+
- BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
3029
- flutter channel master
31-
- export BRANCH=${BRANCH:-'$(git rev-parse --abbrev-ref HEAD)'}
32-
- if [[$BRANCH != "master"]];then
33-
- echo "Running version-check on changed pacakges"
34-
- $PLUGIN_TOOLS version-check --run-on-changed-packages
35-
- else
30+
- if [[ "$BRANCH_NAME" -eq "master" ]]; then
3631
- echo "Running version-check on all packages"
3732
- $PLUGIN_TOOLS version-check
33+
- else
34+
- echo "Running version-check on changed pacakges"
35+
- $PLUGIN_TOOLS version-check --run-on-changed-packages
3836
- fi
3937
- ./script/check_publish.sh
4038
- name: format

script/tool/lib/src/common.dart

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ bool isLinuxPlugin(FileSystemEntity entity, FileSystem fileSystem) {
145145
}
146146

147147
/// Throws a [ToolExit] with `exitCode` and log the `errorMessage` in red.
148-
void PrintErrorAndExit({@required String errorMessage, int exitCode = 1}) {
148+
void printErrorAndExit({@required String errorMessage, int exitCode = 1}) {
149149
final Colorize redError = Colorize(errorMessage)..red();
150150
print(redError);
151151
throw ToolExit(exitCode);
@@ -406,7 +406,7 @@ abstract class PluginCommand extends Command<Null> {
406406
GitDir baseGitDir = gitDir;
407407
if (baseGitDir == null) {
408408
if (!await GitDir.isGitDir(rootDir)) {
409-
PrintErrorAndExit(
409+
printErrorAndExit(
410410
errorMessage: '$rootDir is not a valid Git repository.',
411411
exitCode: 2);
412412
}
@@ -571,12 +571,11 @@ class GitVersionFinder {
571571
final io.ProcessResult changedFilesCommand = await baseGitDir
572572
.runCommand(<String>['diff', '--name-only', '$baseSha', 'HEAD']);
573573
print('Determine diff with base sha: $baseSha');
574-
if (changedFilesCommand.stdout.toString() == null ||
575-
changedFilesCommand.stdout.toString().isEmpty) {
574+
final String changedFilesStdout = changedFilesCommand.stdout.toString() ?? '';
575+
if (changedFilesStdout.isEmpty) {
576576
return <String>[];
577577
}
578-
final List<String> changedFiles = changedFilesCommand.stdout
579-
.toString()
578+
final List<String> changedFiles = changedFilesStdout
580579
.split('\n')
581580
..removeWhere((element) => element.isEmpty);
582581
return changedFiles.toList();
@@ -605,6 +604,6 @@ class GitVersionFinder {
605604
baseShaFromMergeBase = await baseGitDir
606605
.runCommand(<String>['merge-base', 'FETCH_HEAD', 'HEAD']);
607606
}
608-
return (baseShaFromMergeBase.stdout as String).replaceAll('\n', '');
607+
return (baseShaFromMergeBase.stdout as String).trim();
609608
}
610609
}

script/tool/lib/src/version_check_command.dart

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class VersionCheckCommand extends PluginCommand {
109109
@override
110110
final String description =
111111
'Checks if the versions of the plugins have been incremented per pub specification.\n'
112-
'Also checks if the version in CHANGELOG matches the version in pubspec.\n\n'
112+
'Also checks if the latest version in CHANGELOG matches the version in pubspec.\n\n'
113113
'This command requires "pub" and "flutter" to be in your path.';
114114

115115
@override
@@ -147,7 +147,7 @@ class VersionCheckCommand extends PluginCommand {
147147
final String error = '$pubspecPath incorrectly updated version.\n'
148148
'HEAD: $headVersion, master: $masterVersion.\n'
149149
'Allowed versions: $allowedNextVersions';
150-
PrintErrorAndExit(errorMessage: error);
150+
printErrorAndExit(errorMessage: error);
151151
}
152152

153153
bool isPlatformInterface = pubspec.name.endsWith("_platform_interface");
@@ -156,7 +156,7 @@ class VersionCheckCommand extends PluginCommand {
156156
NextVersionType.BREAKING_MAJOR) {
157157
final String error = '$pubspecPath breaking change detected.\n'
158158
'Breaking changes to platform interfaces are strongly discouraged.\n';
159-
PrintErrorAndExit(errorMessage: error);
159+
printErrorAndExit(errorMessage: error);
160160
}
161161
} on io.ProcessException {
162162
print('Unable to find pubspec in master for $pubspecPath.'
@@ -181,7 +181,7 @@ class VersionCheckCommand extends PluginCommand {
181181
final Pubspec pubspec = _tryParsePubspec(plugin);
182182
if (pubspec == null) {
183183
final String error = 'Cannot parse version from pubspec.yaml';
184-
PrintErrorAndExit(errorMessage: error);
184+
printErrorAndExit(errorMessage: error);
185185
}
186186
final Version fromPubspec = pubspec.version;
187187

@@ -191,10 +191,7 @@ class VersionCheckCommand extends PluginCommand {
191191
String firstLineWithText;
192192
final Iterator iterator = lines.iterator;
193193
while (iterator.moveNext()) {
194-
final String currentStriptEmptySpaces =
195-
(iterator.current as String).replaceAll(' ', '');
196-
if (currentStriptEmptySpaces != null &&
197-
currentStriptEmptySpaces.isNotEmpty) {
194+
if ((iterator.current as String).trim().isNotEmpty) {
198195
firstLineWithText = iterator.current;
199196
break;
200197
}
@@ -204,8 +201,8 @@ class VersionCheckCommand extends PluginCommand {
204201
Version fromChangeLog = Version.parse(versionString);
205202
if (fromChangeLog == null) {
206203
final String error =
207-
'Cannot find version on the first line of CHANGELOG.md';
208-
PrintErrorAndExit(errorMessage: error);
204+
'Cannot find version on the first line of ${plugin.path}/CHANGELOG.md';
205+
printErrorAndExit(errorMessage: error);
209206
}
210207

211208
if (fromPubspec != fromChangeLog) {
@@ -214,7 +211,7 @@ versions for $packageName in CHANGELOG.md and pubspec.yaml do not match.
214211
The version in pubspec.yaml is $fromPubspec.
215212
The first version listed in CHANGELOG.md is $fromChangeLog.
216213
''';
217-
PrintErrorAndExit(errorMessage: error);
214+
printErrorAndExit(errorMessage: error);
218215
}
219216
print('${packageName} passed version check');
220217
}
@@ -227,13 +224,13 @@ The first version listed in CHANGELOG.md is $fromChangeLog.
227224
if (pubspec == null) {
228225
final String error =
229226
'Failed to parse `pubspec.yaml` at ${pubspecFile.path}';
230-
PrintErrorAndExit(errorMessage: error);
227+
printErrorAndExit(errorMessage: error);
231228
}
232229
return pubspec;
233230
} on Exception catch (exception) {
234231
final String error =
235232
'Failed to parse `pubspec.yaml` at ${pubspecFile.path}: $exception}';
236-
PrintErrorAndExit(errorMessage: error);
233+
printErrorAndExit(errorMessage: error);
237234
}
238235
return null;
239236
}

0 commit comments

Comments
 (0)