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
ade9f6a9
Unverified
Commit
ade9f6a9
authored
Jul 30, 2021
by
Anurag Roy
Committed by
GitHub
Jul 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Improve toolexit error messages for `flutter upgrade` (#86351)
parent
ed6c9323
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
14 deletions
+23
-14
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+12
-8
upgrade_test.dart
...ter_tools/test/commands.shard/permeable/upgrade_test.dart
+11
-6
No files found.
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
ade9f6a9
...
...
@@ -17,6 +17,9 @@ import '../globals_null_migrated.dart' as globals;
import
'../runner/flutter_command.dart'
;
import
'../version.dart'
;
// The official docs to install Flutter.
const
String
_flutterInstallDocs
=
'https://flutter.dev/docs/get-started/install'
;
class
UpgradeCommand
extends
FlutterCommand
{
UpgradeCommand
({
@required
bool
verboseHelp
,
...
...
@@ -224,7 +227,7 @@ class UpgradeCommandRunner {
/// Returns the remote HEAD flutter version.
///
/// Exits tool if there is no upstream.
/// Exits tool if
HEAD isn't pointing to a branch, or
there is no upstream.
Future
<
FlutterVersion
>
fetchLatestVersion
()
async
{
String
revision
;
try
{
...
...
@@ -245,16 +248,17 @@ class UpgradeCommandRunner {
final
String
errorString
=
e
.
toString
();
if
(
errorString
.
contains
(
'fatal: HEAD does not point to a branch'
))
{
throwToolExit
(
'
You are not currently on a release branch. Use git to
'
"check out an official branch ('stable', 'beta', 'dev', or 'master') "
'
and retry, for example:
\n
'
'
git checkout stable
'
'
Unable to upgrade Flutter: Your Flutter checkout is currently not
'
'on a release branch.
\n
'
'
Use "flutter channel" to switch to an official channel, and retry.
'
'
Alternatively, re-install Flutter by going to
$_flutterInstallDocs
.
'
);
}
else
if
(
errorString
.
contains
(
'fatal: no upstream configured for branch'
))
{
throwToolExit
(
'Unable to upgrade Flutter: no origin repository configured. '
"Run 'git remote add origin "
"https://github.com/flutter/flutter' in
$workingDirectory
"
);
'Unable to upgrade Flutter: The current Flutter branch/channel is '
'not tracking any remote repository.
\n
'
'Re-install Flutter by going to
$_flutterInstallDocs
.'
);
}
else
{
throwToolExit
(
errorString
);
}
...
...
packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
View file @
ade9f6a9
...
...
@@ -199,8 +199,12 @@ void main() {
]);
await
expectLater
(
()
async
=>
realCommandRunner
.
fetchLatestVersion
(),
throwsToolExit
(
message:
'You are not currently on a release branch.'
),
()
async
=>
realCommandRunner
.
fetchLatestVersion
(),
throwsToolExit
(
message:
'Unable to upgrade Flutter: Your Flutter checkout '
'is currently not on a release branch.
\n
'
'Use "flutter channel" to switch to an official channel, and retry. '
'Alternatively, re-install Flutter by going to https://flutter.dev/docs/get-started/install.'
),
);
expect
(
processManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -208,7 +212,7 @@ void main() {
Platform:
()
=>
fakePlatform
,
});
testUsingContext
(
'fetch
RemoteRevi
sion throws toolExit if no upstream configured'
,
()
async
{
testUsingContext
(
'fetch
LatestVer
sion throws toolExit if no upstream configured'
,
()
async
{
processManager
.
addCommands
(
const
<
FakeCommand
>[
FakeCommand
(
command:
<
String
>[
'git'
,
'fetch'
,
'--tags'
...
...
@@ -224,9 +228,10 @@ void main() {
]);
await
expectLater
(
()
async
=>
realCommandRunner
.
fetchLatestVersion
(),
throwsToolExit
(
message:
'Unable to upgrade Flutter: no origin repository configured.'
,
()
async
=>
realCommandRunner
.
fetchLatestVersion
(),
throwsToolExit
(
message:
'Unable to upgrade Flutter: The current Flutter '
'branch/channel is not tracking any remote repository.
\n
'
'Re-install Flutter by going to https://flutter.dev/docs/get-started/install.'
),
);
expect
(
processManager
,
hasNoRemainingExpectations
);
...
...
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