begin migrating //flutter/dev/tools to null-safety (#80834)
This commit is contained in:
committed by
GitHub
parent
e5414695d4
commit
8654e4ae3e
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:io' as io;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:file/file.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:meta/meta.dart' show visibleForTesting;
|
||||
import 'package:platform/platform.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
@@ -31,11 +31,10 @@ const String kUpstream = 'upstream';
|
||||
/// Command to codesign and verify the signatures of cached binaries.
|
||||
class CodesignCommand extends Command<void> {
|
||||
CodesignCommand({
|
||||
@required this.checkouts,
|
||||
@required this.flutterRoot,
|
||||
FrameworkRepository framework,
|
||||
}) : assert(flutterRoot != null),
|
||||
fileSystem = checkouts.fileSystem,
|
||||
required this.checkouts,
|
||||
required this.flutterRoot,
|
||||
FrameworkRepository? framework,
|
||||
}) : fileSystem = checkouts.fileSystem,
|
||||
platform = checkouts.platform,
|
||||
stdio = checkouts.stdio,
|
||||
processManager = checkouts.processManager {
|
||||
@@ -74,7 +73,7 @@ class CodesignCommand extends Command<void> {
|
||||
/// Root directory of the Flutter repository.
|
||||
final Directory flutterRoot;
|
||||
|
||||
FrameworkRepository _framework;
|
||||
FrameworkRepository? _framework;
|
||||
FrameworkRepository get framework {
|
||||
return _framework ??= FrameworkRepository.localRepoAsUpstream(
|
||||
checkouts,
|
||||
@@ -97,21 +96,21 @@ class CodesignCommand extends Command<void> {
|
||||
'"${platform.operatingSystem}"');
|
||||
}
|
||||
|
||||
if (argResults['verify'] as bool != true) {
|
||||
if (argResults!['verify'] as bool != true) {
|
||||
throw ConductorException(
|
||||
'Sorry, but codesigning is not implemented yet. Please pass the '
|
||||
'--$kVerify flag to verify signatures.');
|
||||
}
|
||||
|
||||
String revision;
|
||||
if (argResults.wasParsed(kRevision)) {
|
||||
if (argResults!.wasParsed(kRevision)) {
|
||||
stdio.printError(
|
||||
'Warning! When providing an arbitrary revision, the contents of the cache may not');
|
||||
stdio.printError(
|
||||
'match the expected binaries in the conductor tool. It is preferred to check out');
|
||||
stdio.printError(
|
||||
'the desired revision and run that version of the conductor.\n');
|
||||
revision = argResults[kRevision] as String;
|
||||
revision = argResults![kRevision] as String;
|
||||
} else {
|
||||
revision = (processManager.runSync(
|
||||
<String>['git', 'rev-parse', 'HEAD'],
|
||||
@@ -127,7 +126,7 @@ class CodesignCommand extends Command<void> {
|
||||
framework.runFlutter(<String>['precache', '--android', '--ios', '--macos']);
|
||||
|
||||
verifyExist();
|
||||
if (argResults[kSignatures] as bool) {
|
||||
if (argResults![kSignatures] as bool) {
|
||||
verifySignatures();
|
||||
}
|
||||
}
|
||||
@@ -319,16 +318,16 @@ class CodesignCommand extends Command<void> {
|
||||
}
|
||||
|
||||
stdio.printStatus(
|
||||
'Verified that binaries for commit ${argResults[kRevision] as String} are codesigned and have '
|
||||
'Verified that binaries for commit ${argResults![kRevision] as String} are codesigned and have '
|
||||
'expected entitlements.');
|
||||
}
|
||||
|
||||
List<String> _allBinaryPaths;
|
||||
List<String>? _allBinaryPaths;
|
||||
|
||||
/// Find every binary file in the given [rootDirectory].
|
||||
List<String> findBinaryPaths(String rootDirectory) {
|
||||
if (_allBinaryPaths != null) {
|
||||
return _allBinaryPaths;
|
||||
return _allBinaryPaths!;
|
||||
}
|
||||
final io.ProcessResult result = processManager.runSync(
|
||||
<String>[
|
||||
@@ -343,7 +342,7 @@ class CodesignCommand extends Command<void> {
|
||||
.where((String s) => s.isNotEmpty)
|
||||
.toList();
|
||||
_allBinaryPaths = allFiles.where(isBinary).toList();
|
||||
return _allBinaryPaths;
|
||||
return _allBinaryPaths!;
|
||||
}
|
||||
|
||||
/// Check mime-type of file at [filePath] to determine if it is binary.
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:process/process.dart';
|
||||
|
||||
import './globals.dart';
|
||||
@@ -18,7 +17,7 @@ class Git {
|
||||
String getOutput(
|
||||
List<String> args,
|
||||
String explanation, {
|
||||
@required String workingDirectory,
|
||||
required String workingDirectory,
|
||||
bool allowFailures = false,
|
||||
}) {
|
||||
final ProcessResult result = _run(args, workingDirectory);
|
||||
@@ -26,14 +25,13 @@ class Git {
|
||||
return stdoutToString(result.stdout);
|
||||
}
|
||||
_reportFailureAndExit(args, workingDirectory, result, explanation);
|
||||
return null; // for the analyzer's sake
|
||||
}
|
||||
|
||||
int run(
|
||||
List<String> args,
|
||||
String explanation, {
|
||||
bool allowNonZeroExitCode = false,
|
||||
@required String workingDirectory,
|
||||
required String workingDirectory,
|
||||
}) {
|
||||
final ProcessResult result = _run(args, workingDirectory);
|
||||
if (result.exitCode != 0 && !allowNonZeroExitCode) {
|
||||
@@ -50,7 +48,7 @@ class Git {
|
||||
);
|
||||
}
|
||||
|
||||
void _reportFailureAndExit(
|
||||
Never _reportFailureAndExit(
|
||||
List<String> args,
|
||||
String workingDirectory,
|
||||
ProcessResult result,
|
||||
|
||||
@@ -39,10 +39,10 @@ class ConductorException implements Exception {
|
||||
String toString() => 'Exception: $message';
|
||||
}
|
||||
|
||||
Directory _flutterRoot;
|
||||
Directory? _flutterRoot;
|
||||
Directory get localFlutterRoot {
|
||||
if (_flutterRoot != null) {
|
||||
return _flutterRoot;
|
||||
return _flutterRoot!;
|
||||
}
|
||||
String filePath;
|
||||
const FileSystem fileSystem = LocalFileSystem();
|
||||
@@ -54,14 +54,14 @@ Directory get localFlutterRoot {
|
||||
r'(file:\/\/[^"]*[/\\]dev\/tools[/\\][^"]+\.dart)',
|
||||
multiLine: true,
|
||||
);
|
||||
final Match match =
|
||||
final Match? match =
|
||||
pattern.firstMatch(Uri.decodeFull(platform.script.path));
|
||||
if (match == null) {
|
||||
throw Exception(
|
||||
'Cannot determine path of script!\n${platform.script.path}',
|
||||
);
|
||||
}
|
||||
filePath = Uri.parse(match.group(1)).path.replaceAll(r'%20', ' ');
|
||||
filePath = Uri.parse(match.group(1)!).path.replaceAll(r'%20', ' ');
|
||||
} else {
|
||||
filePath = platform.script.toFilePath();
|
||||
}
|
||||
@@ -74,7 +74,7 @@ Directory get localFlutterRoot {
|
||||
),
|
||||
);
|
||||
_flutterRoot = fileSystem.directory(checkoutsDirname);
|
||||
return _flutterRoot;
|
||||
return _flutterRoot!;
|
||||
}
|
||||
|
||||
bool assertsEnabled() {
|
||||
@@ -102,9 +102,9 @@ String getValueFromEnvOrArgs(
|
||||
) {
|
||||
final String envName = fromArgToEnvName(name);
|
||||
if (env[envName] != null ) {
|
||||
return env[envName];
|
||||
return env[envName]!;
|
||||
}
|
||||
final String argValue = argResults[name] as String;
|
||||
final String? argValue = argResults[name] as String?;
|
||||
if (argValue != null) {
|
||||
return argValue;
|
||||
}
|
||||
@@ -130,7 +130,7 @@ List<String> getValuesFromEnvOrArgs(
|
||||
) {
|
||||
final String envName = fromArgToEnvName(name);
|
||||
if (env[envName] != null && env[envName] != '') {
|
||||
return env[envName].split(',');
|
||||
return env[envName]!.split(',');
|
||||
}
|
||||
final List<String> argValues = argResults[name] as List<String>;
|
||||
if (argValues != null) {
|
||||
|
||||
@@ -23,8 +23,8 @@ enum RemoteName {
|
||||
|
||||
class Remote {
|
||||
const Remote({
|
||||
@required RemoteName name,
|
||||
@required this.url,
|
||||
required RemoteName name,
|
||||
required this.url,
|
||||
}) : _name = name;
|
||||
|
||||
final RemoteName _name;
|
||||
@@ -37,7 +37,6 @@ class Remote {
|
||||
case RemoteName.mirror:
|
||||
return 'mirror';
|
||||
}
|
||||
throw ConductorException('Invalid value of _name: $_name'); // For analyzer
|
||||
}
|
||||
|
||||
/// The URL of the remote.
|
||||
@@ -47,13 +46,13 @@ class Remote {
|
||||
/// A source code repository.
|
||||
abstract class Repository {
|
||||
Repository({
|
||||
@required this.name,
|
||||
@required this.fetchRemote,
|
||||
@required this.processManager,
|
||||
@required this.stdio,
|
||||
@required this.platform,
|
||||
@required this.fileSystem,
|
||||
@required this.parentDirectory,
|
||||
required this.name,
|
||||
required this.fetchRemote,
|
||||
required this.processManager,
|
||||
required this.stdio,
|
||||
required this.platform,
|
||||
required this.fileSystem,
|
||||
required this.parentDirectory,
|
||||
this.initialRef,
|
||||
this.localUpstream = false,
|
||||
this.useExistingCheckout = false,
|
||||
@@ -69,10 +68,10 @@ abstract class Repository {
|
||||
///
|
||||
/// This value can be null, in which case attempting to publish will lead to
|
||||
/// a [ConductorException].
|
||||
final Remote pushRemote;
|
||||
final Remote? pushRemote;
|
||||
|
||||
/// The initial ref (branch or commit name) to check out.
|
||||
final String initialRef;
|
||||
final String? initialRef;
|
||||
final Git git;
|
||||
final ProcessManager processManager;
|
||||
final Stdio stdio;
|
||||
@@ -84,7 +83,7 @@ abstract class Repository {
|
||||
/// If the repository will be used as an upstream for a test repo.
|
||||
final bool localUpstream;
|
||||
|
||||
Directory _checkoutDirectory;
|
||||
Directory? _checkoutDirectory;
|
||||
|
||||
/// Directory for the repository checkout.
|
||||
///
|
||||
@@ -92,23 +91,23 @@ abstract class Repository {
|
||||
/// cloned on the filesystem until this getter is accessed.
|
||||
Directory get checkoutDirectory {
|
||||
if (_checkoutDirectory != null) {
|
||||
return _checkoutDirectory;
|
||||
return _checkoutDirectory!;
|
||||
}
|
||||
_checkoutDirectory = parentDirectory.childDirectory(name);
|
||||
lazilyInitialize();
|
||||
return _checkoutDirectory;
|
||||
lazilyInitialize(_checkoutDirectory!);
|
||||
return _checkoutDirectory!;
|
||||
}
|
||||
|
||||
/// Ensure the repository is cloned to disk and initialized with proper state.
|
||||
void lazilyInitialize() {
|
||||
if (!useExistingCheckout && _checkoutDirectory.existsSync()) {
|
||||
stdio.printTrace('Deleting $name from ${_checkoutDirectory.path}...');
|
||||
_checkoutDirectory.deleteSync(recursive: true);
|
||||
void lazilyInitialize(Directory checkoutDirectory) {
|
||||
if (!useExistingCheckout && checkoutDirectory.existsSync()) {
|
||||
stdio.printTrace('Deleting $name from ${checkoutDirectory.path}...');
|
||||
checkoutDirectory.deleteSync(recursive: true);
|
||||
}
|
||||
|
||||
if (!_checkoutDirectory.existsSync()) {
|
||||
if (!checkoutDirectory.existsSync()) {
|
||||
stdio.printTrace(
|
||||
'Cloning $name from ${fetchRemote.url} to ${_checkoutDirectory.path}...',
|
||||
'Cloning $name from ${fetchRemote.url} to ${checkoutDirectory.path}...',
|
||||
);
|
||||
git.run(
|
||||
<String>[
|
||||
@@ -117,21 +116,21 @@ abstract class Repository {
|
||||
fetchRemote.name,
|
||||
'--',
|
||||
fetchRemote.url,
|
||||
_checkoutDirectory.path
|
||||
checkoutDirectory.path
|
||||
],
|
||||
'Cloning $name repo',
|
||||
workingDirectory: parentDirectory.path,
|
||||
);
|
||||
if (pushRemote != null) {
|
||||
git.run(
|
||||
<String>['remote', 'add', pushRemote.name, pushRemote.url],
|
||||
'Adding remote ${pushRemote.url} as ${pushRemote.name}',
|
||||
workingDirectory: _checkoutDirectory.path,
|
||||
<String>['remote', 'add', pushRemote!.name, pushRemote!.url],
|
||||
'Adding remote ${pushRemote!.url} as ${pushRemote!.name}',
|
||||
workingDirectory: checkoutDirectory.path,
|
||||
);
|
||||
git.run(
|
||||
<String>['fetch', pushRemote.name],
|
||||
'Fetching git remote ${pushRemote.name}',
|
||||
workingDirectory: _checkoutDirectory.path,
|
||||
<String>['fetch', pushRemote!.name],
|
||||
'Fetching git remote ${pushRemote!.name}',
|
||||
workingDirectory: checkoutDirectory.path,
|
||||
);
|
||||
}
|
||||
if (localUpstream) {
|
||||
@@ -141,7 +140,7 @@ abstract class Repository {
|
||||
git.run(
|
||||
<String>['checkout', channel, '--'],
|
||||
'check out branch $channel locally',
|
||||
workingDirectory: _checkoutDirectory.path,
|
||||
workingDirectory: checkoutDirectory.path,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -151,7 +150,7 @@ abstract class Repository {
|
||||
git.run(
|
||||
<String>['checkout', '${fetchRemote.name}/$initialRef'],
|
||||
'Checking out initialRef $initialRef',
|
||||
workingDirectory: _checkoutDirectory.path,
|
||||
workingDirectory: checkoutDirectory.path,
|
||||
);
|
||||
}
|
||||
final String revision = reverseParse('HEAD');
|
||||
@@ -404,8 +403,8 @@ class FrameworkRepository extends Repository {
|
||||
name: RemoteName.upstream, url: FrameworkRepository.defaultUpstream),
|
||||
bool localUpstream = false,
|
||||
bool useExistingCheckout = false,
|
||||
String initialRef,
|
||||
Remote pushRemote,
|
||||
String? initialRef,
|
||||
Remote? pushRemote,
|
||||
}) : super(
|
||||
name: name,
|
||||
fetchRemote: fetchRemote,
|
||||
@@ -428,7 +427,7 @@ class FrameworkRepository extends Repository {
|
||||
Checkouts checkouts, {
|
||||
String name = 'framework',
|
||||
bool useExistingCheckout = false,
|
||||
@required String upstreamPath,
|
||||
required String upstreamPath,
|
||||
}) {
|
||||
return FrameworkRepository(
|
||||
checkouts,
|
||||
@@ -455,7 +454,7 @@ class FrameworkRepository extends Repository {
|
||||
);
|
||||
|
||||
@override
|
||||
Repository cloneRepository(String cloneName) {
|
||||
Repository cloneRepository(String? cloneName) {
|
||||
assert(localUpstream);
|
||||
cloneName ??= 'clone-of-$name';
|
||||
return FrameworkRepository(
|
||||
@@ -529,7 +528,7 @@ class EngineRepository extends Repository {
|
||||
name: RemoteName.upstream, url: EngineRepository.defaultUpstream),
|
||||
bool localUpstream = false,
|
||||
bool useExistingCheckout = false,
|
||||
Remote pushRemote,
|
||||
Remote? pushRemote,
|
||||
}) : super(
|
||||
name: name,
|
||||
fetchRemote: fetchRemote,
|
||||
@@ -550,7 +549,7 @@ class EngineRepository extends Repository {
|
||||
static const String defaultBranch = 'master';
|
||||
|
||||
@override
|
||||
Repository cloneRepository(String cloneName) {
|
||||
Repository cloneRepository(String? cloneName) {
|
||||
assert(localUpstream);
|
||||
cloneName ??= 'clone-of-$name';
|
||||
return EngineRepository(
|
||||
@@ -571,14 +570,13 @@ enum RepositoryType {
|
||||
|
||||
class Checkouts {
|
||||
Checkouts({
|
||||
@required this.fileSystem,
|
||||
@required this.platform,
|
||||
@required this.processManager,
|
||||
@required this.stdio,
|
||||
@required Directory parentDirectory,
|
||||
required this.fileSystem,
|
||||
required this.platform,
|
||||
required this.processManager,
|
||||
required this.stdio,
|
||||
required Directory parentDirectory,
|
||||
String directoryName = 'flutter_conductor_checkouts',
|
||||
}) : assert(parentDirectory != null),
|
||||
directory = parentDirectory.childDirectory(directoryName) {
|
||||
}) : directory = parentDirectory.childDirectory(directoryName) {
|
||||
if (!directory.existsSync()) {
|
||||
directory.createSync(recursive: true);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ const String kSkipTagging = 'skip-tagging';
|
||||
/// Create a new dev release without cherry picks.
|
||||
class RollDevCommand extends Command<void> {
|
||||
RollDevCommand({
|
||||
@required this.checkouts,
|
||||
@required this.fileSystem,
|
||||
@required this.platform,
|
||||
@required this.stdio,
|
||||
required this.checkouts,
|
||||
required this.fileSystem,
|
||||
required this.platform,
|
||||
required this.stdio,
|
||||
}) {
|
||||
argParser.addOption(
|
||||
kIncrement,
|
||||
@@ -92,7 +92,7 @@ class RollDevCommand extends Command<void> {
|
||||
@override
|
||||
void run() {
|
||||
rollDev(
|
||||
argResults: argResults,
|
||||
argResults: argResults!,
|
||||
repository: FrameworkRepository(checkouts),
|
||||
stdio: stdio,
|
||||
usage: argParser.usage,
|
||||
@@ -105,10 +105,10 @@ class RollDevCommand extends Command<void> {
|
||||
/// Returns true if publishing was successful, else false.
|
||||
@visibleForTesting
|
||||
bool rollDev({
|
||||
@required String usage,
|
||||
@required ArgResults argResults,
|
||||
@required Stdio stdio,
|
||||
@required FrameworkRepository repository,
|
||||
required String usage,
|
||||
required ArgResults argResults,
|
||||
required Stdio stdio,
|
||||
required FrameworkRepository repository,
|
||||
}) {
|
||||
final String remoteName = argResults[kRemoteName] as String;
|
||||
final String level = argResults[kIncrement] as String;
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:convert' show jsonEncode;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import './globals.dart';
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:convert' show jsonDecode;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
@@ -40,10 +40,10 @@ abstract class Stdio {
|
||||
/// A logger that will print out trace messages.
|
||||
class VerboseStdio extends Stdio {
|
||||
VerboseStdio({
|
||||
@required this.stdout,
|
||||
@required this.stderr,
|
||||
@required this.stdin,
|
||||
}) : assert(stdout != null), assert(stderr != null), assert(stdin != null);
|
||||
required this.stdout,
|
||||
required this.stderr,
|
||||
required this.stdin,
|
||||
});
|
||||
|
||||
factory VerboseStdio.local() => VerboseStdio(
|
||||
stdout: io.stdout,
|
||||
@@ -81,6 +81,6 @@ class VerboseStdio extends Stdio {
|
||||
|
||||
@override
|
||||
String readLineSync() {
|
||||
return stdin.readLineSync();
|
||||
return stdin.readLineSync()!;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
/// Possible string formats that `flutter --version` can return.
|
||||
enum VersionType {
|
||||
/// A stable flutter release.
|
||||
///
|
||||
/// Example: '1.2.3'
|
||||
stable,
|
||||
|
||||
/// A pre-stable flutter release.
|
||||
///
|
||||
/// Example: '1.2.3-4.5.pre'
|
||||
development,
|
||||
|
||||
/// A master channel flutter version.
|
||||
///
|
||||
/// Example: '1.2.3-4.0.pre.10'
|
||||
@@ -30,13 +30,13 @@ final Map<VersionType, RegExp> versionPatterns = <VersionType, RegExp>{
|
||||
|
||||
class Version {
|
||||
Version({
|
||||
@required this.x,
|
||||
@required this.y,
|
||||
@required this.z,
|
||||
required this.x,
|
||||
required this.y,
|
||||
required this.z,
|
||||
this.m,
|
||||
this.n,
|
||||
this.commits,
|
||||
@required this.type,
|
||||
required this.type,
|
||||
}) {
|
||||
switch (type) {
|
||||
case VersionType.stable:
|
||||
@@ -67,11 +67,13 @@ class Version {
|
||||
|
||||
versionString = versionString.trim();
|
||||
// stable tag
|
||||
Match match = versionPatterns[VersionType.stable].firstMatch(versionString);
|
||||
Match? match = versionPatterns[VersionType.stable]!.firstMatch(versionString);
|
||||
if (match != null) {
|
||||
// parse stable
|
||||
final List<int> parts =
|
||||
match.groups(<int>[1, 2, 3]).map(int.parse).toList();
|
||||
final List<int> parts = match
|
||||
.groups(<int>[1, 2, 3])
|
||||
.map((String? s) => int.parse(s!))
|
||||
.toList();
|
||||
return Version(
|
||||
x: parts[0],
|
||||
y: parts[1],
|
||||
@@ -80,11 +82,11 @@ class Version {
|
||||
);
|
||||
}
|
||||
// development tag
|
||||
match = versionPatterns[VersionType.development].firstMatch(versionString);
|
||||
match = versionPatterns[VersionType.development]!.firstMatch(versionString);
|
||||
if (match != null) {
|
||||
// parse development
|
||||
final List<int> parts =
|
||||
match.groups(<int>[1, 2, 3, 4, 5]).map(int.parse).toList();
|
||||
match.groups(<int>[1, 2, 3, 4, 5]).map((String? s) => int.parse(s!)).toList();
|
||||
return Version(
|
||||
x: parts[0],
|
||||
y: parts[1],
|
||||
@@ -95,11 +97,14 @@ class Version {
|
||||
);
|
||||
}
|
||||
// latest tag
|
||||
match = versionPatterns[VersionType.latest].firstMatch(versionString);
|
||||
match = versionPatterns[VersionType.latest]!.firstMatch(versionString);
|
||||
if (match != null) {
|
||||
// parse latest
|
||||
final List<int> parts =
|
||||
match.groups(<int>[1, 2, 3, 4, 5, 6]).map(int.parse).toList();
|
||||
final List<int> parts = match.groups(
|
||||
<int>[1, 2, 3, 4, 5, 6],
|
||||
).map(
|
||||
(String? s) => int.parse(s!),
|
||||
).toList();
|
||||
return Version(
|
||||
x: parts[0],
|
||||
y: parts[1],
|
||||
@@ -118,13 +123,13 @@ class Version {
|
||||
factory Version.increment(
|
||||
Version previousVersion,
|
||||
String increment, {
|
||||
VersionType nextVersionType,
|
||||
VersionType? nextVersionType,
|
||||
}) {
|
||||
final int nextX = previousVersion.x;
|
||||
int nextY = previousVersion.y;
|
||||
int nextZ = previousVersion.z;
|
||||
int nextM = previousVersion.m;
|
||||
int nextN = previousVersion.n;
|
||||
int? nextM = previousVersion.m;
|
||||
int? nextN = previousVersion.n;
|
||||
if (nextVersionType == null) {
|
||||
if (previousVersion.type == VersionType.latest) {
|
||||
nextVersionType = VersionType.development;
|
||||
@@ -137,7 +142,6 @@ class Version {
|
||||
case 'x':
|
||||
// This was probably a mistake.
|
||||
throw Exception('Incrementing x is not supported by this tool.');
|
||||
break;
|
||||
case 'y':
|
||||
// Dev release following a beta release.
|
||||
nextY += 1;
|
||||
@@ -155,13 +159,12 @@ class Version {
|
||||
case 'm':
|
||||
// Regular dev release.
|
||||
assert(previousVersion.type == VersionType.development);
|
||||
assert(nextM != null);
|
||||
nextM += 1;
|
||||
nextM = nextM! + 1;
|
||||
nextN = 0;
|
||||
break;
|
||||
case 'n':
|
||||
// Hotfix to internal roll.
|
||||
nextN += 1;
|
||||
nextN = nextN! + 1;
|
||||
break;
|
||||
default:
|
||||
throw Exception('Unknown increment level $increment.');
|
||||
@@ -186,13 +189,13 @@ class Version {
|
||||
final int z;
|
||||
|
||||
/// Zero-indexed count of dev releases after a beta release.
|
||||
final int m;
|
||||
final int? m;
|
||||
|
||||
/// Number of hotfixes required to make a dev release.
|
||||
final int n;
|
||||
final int? n;
|
||||
|
||||
/// Number of commits past last tagged dev release.
|
||||
final int commits;
|
||||
final int? commits;
|
||||
|
||||
final VersionType type;
|
||||
|
||||
@@ -206,6 +209,5 @@ class Version {
|
||||
case VersionType.latest:
|
||||
return '$x.$y.$z-$m.$n.pre.$commits';
|
||||
}
|
||||
return null; // For analyzer
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user