[flutter_tools] remove branch migration and standardize constructor style for version interface (#70058)
diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 3ec6bcd..6d679d3 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart
@@ -16,17 +16,6 @@ /// The flutter GitHub repository. String get _flutterGit => globals.platform.environment['FLUTTER_GIT_URL'] ?? 'https://github.com/flutter/flutter.git'; -/// This maps old branch names to the names of branches that replaced them. -/// -/// For example, in early 2018 we changed from having an "alpha" branch to -/// having a "dev" branch, so anyone using "alpha" now gets transitioned to -/// "dev". -const Map<String, String> kObsoleteBranches = <String, String>{ - 'alpha': 'dev', - 'hackathon': 'dev', - 'codelab': 'dev', -}; - /// The names of each channel/branch in order of increasing stability. enum Channel { master, @@ -67,7 +56,11 @@ /// /// Call [fetchTagsAndUpdate] to update the version based on the latest tags /// available upstream. - FlutterVersion([this._clock = const SystemClock(), this._workingDirectory]) { + FlutterVersion({ + SystemClock clock = const SystemClock(), + String workingDirectory, + }) : _clock = clock, + _workingDirectory = workingDirectory { _frameworkRevision = _runGit( gitLog(<String>['-n', '1', '--pretty=format:%H']).join(' '), globals.processUtils, @@ -77,6 +70,9 @@ _frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision); } + final SystemClock _clock; + final String _workingDirectory; + /// Fetches tags from the upstream Flutter repository and re-calculates the /// version. /// @@ -88,21 +84,12 @@ _frameworkVersion = gitTagVersion.frameworkVersionFor(_frameworkRevision); } - final SystemClock _clock; - final String _workingDirectory; - String _repositoryUrl; String get repositoryUrl { final String _ = channel; return _repositoryUrl; } - /// Whether we are currently on the master branch. - bool get isMaster { - final String branchName = getBranchName(); - return !<String>['dev', 'beta', 'stable'].contains(branchName); - } - String _channel; /// The channel is the upstream branch. /// `master`, `dev`, `beta`, `stable`; or old ones, like `alpha`, `hackathon`, ... @@ -161,9 +148,8 @@ String get engineRevision => globals.cache.engineRevision; String get engineRevisionShort => _shortGitRevision(engineRevision); - Future<void> ensureVersionFile() { + void ensureVersionFile() { globals.fs.file(globals.fs.path.join(Cache.flutterRoot, 'version')).writeAsStringSync(_frameworkVersion); - return Future<void>.value(); } @override @@ -298,8 +284,7 @@ }(); if (redactUnknownBranches || _branch.isEmpty) { // Only return the branch names we know about; arbitrary branch names might contain PII. - if (!kOfficialChannels.contains(_branch) && - !kObsoleteBranches.containsKey(_branch)) { + if (!kOfficialChannels.contains(_branch)) { return '[user-branch]'; } }