Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
12ba9046
Unverified
Commit
12ba9046
authored
Apr 07, 2021
by
Jenn Magder
Committed by
GitHub
Apr 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate tool version to null safety (#79911)
parent
bf41c839
Changes
11
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
171 additions
and
169 deletions
+171
-169
process.dart
packages/flutter_tools/lib/src/base/process.dart
+16
-16
channel.dart
packages/flutter_tools/lib/src/commands/channel.dart
+1
-1
create.dart
packages/flutter_tools/lib/src/commands/create.dart
+1
-1
create_base.dart
packages/flutter_tools/lib/src/commands/create_base.dart
+1
-1
globals.dart
packages/flutter_tools/lib/src/globals.dart
+0
-2
globals_null_migrated.dart
packages/flutter_tools/lib/src/globals_null_migrated.dart
+2
-0
sksl_writer.dart
packages/flutter_tools/lib/src/sksl_writer.dart
+1
-1
version.dart
packages/flutter_tools/lib/src/version.dart
+77
-95
flutter_command_runner_test.dart
...est/general.shard/runner/flutter_command_runner_test.dart
+1
-1
version_test.dart
packages/flutter_tools/test/general.shard/version_test.dart
+71
-46
fakes.dart
packages/flutter_tools/test/src/fakes.dart
+0
-5
No files found.
packages/flutter_tools/lib/src/base/process.dart
View file @
12ba9046
...
...
@@ -167,11 +167,11 @@ abstract class ProcessUtils {
Future
<
RunResult
>
run
(
List
<
String
>
cmd
,
{
bool
throwOnError
=
false
,
RunResultChecker
allowedFailures
,
String
workingDirectory
,
RunResultChecker
?
allowedFailures
,
String
?
workingDirectory
,
bool
allowReentrantFlutter
=
false
,
Map
<
String
,
String
>
environment
,
Duration
timeout
,
Map
<
String
,
String
>
?
environment
,
Duration
?
timeout
,
int
timeoutRetries
=
0
,
});
...
...
@@ -180,10 +180,10 @@ abstract class ProcessUtils {
List
<
String
>
cmd
,
{
bool
throwOnError
=
false
,
bool
verboseExceptions
=
false
,
RunResultChecker
allowedFailures
,
RunResultChecker
?
allowedFailures
,
bool
hideStdout
=
false
,
String
workingDirectory
,
Map
<
String
,
String
>
environment
,
String
?
workingDirectory
,
Map
<
String
,
String
>
?
environment
,
bool
allowReentrantFlutter
=
false
,
Encoding
encoding
=
systemEncoding
,
});
...
...
@@ -192,9 +192,9 @@ abstract class ProcessUtils {
/// directory. Completes when the process has been started.
Future
<
Process
>
start
(
List
<
String
>
cmd
,
{
String
workingDirectory
,
String
?
workingDirectory
,
bool
allowReentrantFlutter
=
false
,
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
?
environment
,
});
/// This runs the command and streams stdout/stderr from the child process to
...
...
@@ -210,24 +210,24 @@ abstract class ProcessUtils {
/// treated as errors, just as if they had been logged to stderr instead.
Future
<
int
>
stream
(
List
<
String
>
cmd
,
{
String
workingDirectory
,
String
?
workingDirectory
,
bool
allowReentrantFlutter
=
false
,
String
prefix
=
''
,
bool
trace
=
false
,
RegExp
filter
,
RegExp
stdoutErrorMatcher
,
StringConverter
mapFunction
,
Map
<
String
,
String
>
environment
,
RegExp
?
filter
,
RegExp
?
stdoutErrorMatcher
,
StringConverter
?
mapFunction
,
Map
<
String
,
String
>
?
environment
,
});
bool
exitsHappySync
(
List
<
String
>
cli
,
{
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
?
environment
,
});
Future
<
bool
>
exitsHappy
(
List
<
String
>
cli
,
{
Map
<
String
,
String
>
environment
,
Map
<
String
,
String
>
?
environment
,
});
}
...
...
packages/flutter_tools/lib/src/commands/channel.dart
View file @
12ba9046
...
...
@@ -6,7 +6,7 @@
import
'../base/common.dart'
;
import
'../cache.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals
_null_migrated
.dart'
as
globals
;
import
'../runner/flutter_command.dart'
;
import
'../version.dart'
;
...
...
packages/flutter_tools/lib/src/commands/create.dart
View file @
12ba9046
...
...
@@ -15,7 +15,7 @@ import '../dart/pub.dart';
import
'../features.dart'
;
import
'../flutter_manifest.dart'
;
import
'../flutter_project_metadata.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals
_null_migrated
.dart'
as
globals
;
import
'../project.dart'
;
import
'../reporting/reporting.dart'
;
import
'../runner/flutter_command.dart'
;
...
...
packages/flutter_tools/lib/src/commands/create_base.dart
View file @
12ba9046
...
...
@@ -18,7 +18,7 @@ import '../convert.dart';
import
'../dart/pub.dart'
;
import
'../features.dart'
;
import
'../flutter_project_metadata.dart'
;
import
'../globals.dart'
as
globals
;
import
'../globals
_null_migrated
.dart'
as
globals
;
import
'../project.dart'
;
import
'../runner/flutter_command.dart'
;
import
'../template.dart'
;
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
12ba9046
...
...
@@ -25,7 +25,6 @@ import 'persistent_tool_state.dart';
import
'project.dart'
;
import
'reporting/reporting.dart'
;
import
'runner/local_engine.dart'
;
import
'version.dart'
;
export
'globals_null_migrated.dart'
;
...
...
@@ -49,7 +48,6 @@ CocoaPodsValidator get cocoapodsValidator => context.get<CocoaPodsValidator>();
LocalEngineLocator
get
localEngineLocator
=>
context
.
get
<
LocalEngineLocator
>();
CocoaPods
get
cocoaPods
=>
context
.
get
<
CocoaPods
>();
FlutterVersion
get
flutterVersion
=>
context
.
get
<
FlutterVersion
>();
FuchsiaArtifacts
get
fuchsiaArtifacts
=>
context
.
get
<
FuchsiaArtifacts
>();
IOSSimulatorUtils
get
iosSimulatorUtils
=>
context
.
get
<
IOSSimulatorUtils
>();
IOSWorkflow
get
iosWorkflow
=>
context
.
get
<
IOSWorkflow
>();
...
...
packages/flutter_tools/lib/src/globals_null_migrated.dart
View file @
12ba9046
...
...
@@ -23,6 +23,7 @@ import 'base/time.dart';
import
'base/user_messages.dart'
;
import
'cache.dart'
;
import
'ios/plist_parser.dart'
;
import
'version.dart'
;
Cache
get
cache
=>
context
.
get
<
Cache
>()!;
Config
get
config
=>
context
.
get
<
Config
>()!;
...
...
@@ -32,6 +33,7 @@ OperatingSystemUtils get os => context.get<OperatingSystemUtils>()!;
Signals
get
signals
=>
context
.
get
<
Signals
>()
??
LocalSignals
.
instance
;
AndroidStudio
?
get
androidStudio
=>
context
.
get
<
AndroidStudio
>();
AndroidSdk
?
get
androidSdk
=>
context
.
get
<
AndroidSdk
>();
FlutterVersion
get
flutterVersion
=>
context
.
get
<
FlutterVersion
>()!;
/// Currently active implementation of the file system.
///
...
...
packages/flutter_tools/lib/src/sksl_writer.dart
View file @
12ba9046
...
...
@@ -13,7 +13,7 @@ import 'base/logger.dart';
import
'build_info.dart'
;
import
'convert.dart'
;
import
'device.dart'
;
import
'globals.dart'
as
globals
;
import
'globals
_null_migrated
.dart'
as
globals
;
Future
<
String
>
sharedSkSlWriter
(
Device
device
,
Map
<
String
,
Object
>
data
,
{
File
outputFile
,
...
...
packages/flutter_tools/lib/src/version.dart
View file @
12ba9046
This diff is collapsed.
Click to expand it.
packages/flutter_tools/test/general.shard/runner/flutter_command_runner_test.dart
View file @
12ba9046
...
...
@@ -12,7 +12,7 @@ import 'package:flutter_tools/src/base/io.dart';
import
'package:flutter_tools/src/base/platform.dart'
;
import
'package:flutter_tools/src/base/terminal.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/globals
_null_migrated
.dart'
as
globals
;
import
'package:flutter_tools/src/runner/flutter_command.dart'
;
import
'package:flutter_tools/src/runner/flutter_command_runner.dart'
;
import
'package:flutter_tools/src/version.dart'
;
...
...
packages/flutter_tools/test/general.shard/version_test.dart
View file @
12ba9046
...
...
@@ -14,7 +14,7 @@ import 'package:flutter_tools/src/base/process.dart';
import
'package:flutter_tools/src/base/time.dart'
;
import
'package:flutter_tools/src/base/utils.dart'
;
import
'package:flutter_tools/src/cache.dart'
;
import
'package:flutter_tools/src/globals.dart'
as
globals
;
import
'package:flutter_tools/src/globals
_null_migrated
.dart'
as
globals
;
import
'package:flutter_tools/src/version.dart'
;
import
'package:mockito/mockito.dart'
;
...
...
@@ -61,17 +61,6 @@ void main() {
});
testUsingContext
(
'prints nothing when Flutter installation looks fresh'
,
()
async
{
fakeData
(
mockProcessManager
,
mockCache
,
localCommitDate:
getChannelUpToDateVersion
(),
// Server will be pinged because we haven't pinged within last x days
expectServerPing:
true
,
remoteCommitDate:
getChannelOutOfDateVersion
(),
expectSetStamp:
true
,
channel:
channel
,
);
processManager
.
addCommand
(
const
FakeCommand
(
command:
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'-n'
,
'1'
,
'--pretty=format:%H'
],
stdout:
'1234abcd'
,
...
...
@@ -116,7 +105,40 @@ void main() {
command:
<
String
>[
'git'
,
'remote'
],
));
await
globals
.
flutterVersion
.
checkFlutterVersionFreshness
();
processManager
.
addCommands
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'-n'
,
'1'
,
'--pretty=format:%ar'
],
stdout:
'1 second ago'
,
),
FakeCommand
(
command:
const
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'-n'
,
'1'
,
'--pretty=format:%ad'
,
'--date=iso'
],
stdout:
getChannelUpToDateVersion
().
toString
(),
),
FakeCommand
(
command:
const
<
String
>[
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'HEAD'
],
stdout:
channel
,
),
]);
final
FlutterVersion
flutterVersion
=
globals
.
flutterVersion
;
await
flutterVersion
.
checkFlutterVersionFreshness
();
expect
(
flutterVersion
.
channel
,
channel
);
expect
(
flutterVersion
.
frameworkRevision
,
'1234abcd'
);
expect
(
flutterVersion
.
frameworkRevisionShort
,
'1234abcd'
);
expect
(
flutterVersion
.
frameworkVersion
,
'0.0.0-unknown'
);
expect
(
flutterVersion
.
toString
(),
'Flutter • channel
$channel
• unknown source
\n
'
'Framework • revision 1234abcd (1 second ago) •
${getChannelUpToDateVersion()}
\n
'
'Engine • revision
\n
'
'Tools • Dart null'
,
);
expect
(
flutterVersion
.
frameworkAge
,
'1 second ago'
);
expect
(
flutterVersion
.
getVersionString
(),
'
$channel
/1234abcd'
);
expect
(
flutterVersion
.
getBranchName
(),
channel
);
expect
(
flutterVersion
.
getVersionString
(
redactUnknownBranches:
true
),
'
$channel
/1234abcd'
);
expect
(
flutterVersion
.
getBranchName
(
redactUnknownBranches:
true
),
channel
);
_expectVersionMessage
(
''
);
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -291,39 +313,6 @@ void main() {
ProcessManager:
()
=>
mockProcessManager
,
Cache:
()
=>
mockCache
,
});
testUsingContext
(
'versions comparison'
,
()
async
{
fakeData
(
mockProcessManager
,
mockCache
,
localCommitDate:
getChannelOutOfDateVersion
(),
errorOnFetch:
true
,
expectServerPing:
true
,
expectSetStamp:
true
,
channel:
channel
,
);
final
FlutterVersion
version
=
globals
.
flutterVersion
;
when
(
mockProcessManager
.
runSync
(
<
String
>[
'git'
,
'merge-base'
,
'--is-ancestor'
,
'abcdef'
,
'123456'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
)).
thenReturn
(
ProcessResult
(
1
,
0
,
''
,
''
));
expect
(
version
.
checkRevisionAncestry
(
tentativeDescendantRevision:
'123456'
,
tentativeAncestorRevision:
'abcdef'
,
),
true
);
verify
(
mockProcessManager
.
runSync
(
<
String
>[
'git'
,
'merge-base'
,
'--is-ancestor'
,
'abcdef'
,
'123456'
],
workingDirectory:
anyNamed
(
'workingDirectory'
),
));
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
FlutterVersion
(
clock:
_testClock
),
ProcessManager:
()
=>
mockProcessManager
,
});
});
group
(
'
$VersionCheckStamp
for
$channel
'
,
()
{
...
...
@@ -449,6 +438,42 @@ void main() {
});
}
testUsingContext
(
'version handles unknown branch'
,
()
async
{
processManager
.
addCommands
(<
FakeCommand
>[
const
FakeCommand
(
command:
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'-n'
,
'1'
,
'--pretty=format:%H'
],
stdout:
'1234abcd'
,
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'tag'
,
'--points-at'
,
'1234abcd'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'describe'
,
'--match'
,
'*.*.*'
,
'--long'
,
'--tags'
,
'1234abcd'
],
stdout:
'0.1.2-3-1234abcd'
,
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'--symbolic'
,
'@{u}'
],
stdout:
'feature-branch'
,
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'HEAD'
],
stdout:
'feature-branch'
,
),
]);
final
FlutterVersion
flutterVersion
=
globals
.
flutterVersion
;
expect
(
flutterVersion
.
channel
,
'feature-branch'
);
expect
(
flutterVersion
.
getVersionString
(),
'feature-branch/1234abcd'
);
expect
(
flutterVersion
.
getBranchName
(),
'feature-branch'
);
expect
(
flutterVersion
.
getVersionString
(
redactUnknownBranches:
true
),
'[user-branch]/1234abcd'
);
expect
(
flutterVersion
.
getBranchName
(
redactUnknownBranches:
true
),
'[user-branch]'
);
expect
(
processManager
.
hasRemainingExpectations
,
isFalse
);
},
overrides:
<
Type
,
Generator
>{
FlutterVersion:
()
=>
FlutterVersion
(
clock:
_testClock
),
ProcessManager:
()
=>
processManager
,
Cache:
()
=>
mockCache
,
});
testUsingContext
(
'GitTagVersion'
,
()
{
const
String
hash
=
'abcdef'
;
GitTagVersion
gitTagVersion
;
...
...
packages/flutter_tools/test/src/fakes.dart
View file @
12ba9046
...
...
@@ -526,11 +526,6 @@ class FakeFlutterVersion implements FlutterVersion {
_didCheckFlutterVersionFreshness
=
true
;
}
@override
bool
checkRevisionAncestry
({
String
tentativeDescendantRevision
,
String
tentativeAncestorRevision
})
{
throw
UnimplementedError
();
}
@override
Future
<
void
>
ensureVersionFile
()
async
{
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment