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
069dc9c7
Unverified
Commit
069dc9c7
authored
Apr 27, 2020
by
Christopher Fujino
Committed by
GitHub
Apr 27, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] catch ProcessException and throw ToolExit during upgrade (#55759)
parent
2aa90166
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
10 deletions
+31
-10
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+10
-9
upgrade_test.dart
...ter_tools/test/commands.shard/permeable/upgrade_test.dart
+21
-1
No files found.
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
069dc9c7
...
...
@@ -137,7 +137,7 @@ class UpgradeCommandRunner {
}
recordState
(
flutterVersion
);
await
upgradeChannel
(
flutterVersion
);
await
attemptReset
(
flutterVersion
,
upstreamRevision
);
await
attemptReset
(
upstreamRevision
);
if
(!
testFlow
)
{
await
flutterUpgradeContinue
();
}
...
...
@@ -243,14 +243,15 @@ class UpgradeCommandRunner {
/// This is a reset instead of fast forward because if we are on a release
/// branch with cherry picks, there may not be a direct fast-forward route
/// to the next release.
Future
<
void
>
attemptReset
(
FlutterVersion
oldFlutterVersion
,
String
newRevision
)
async
{
final
RunResult
result
=
await
processUtils
.
run
(
<
String
>[
'git'
,
'reset'
,
'--hard'
,
newRevision
],
throwOnError:
true
,
workingDirectory:
workingDirectory
,
);
if
(
result
.
exitCode
!=
0
)
{
throwToolExit
(
null
,
exitCode:
result
.
exitCode
);
Future
<
void
>
attemptReset
(
String
newRevision
)
async
{
try
{
await
processUtils
.
run
(
<
String
>[
'git'
,
'reset'
,
'--hard'
,
newRevision
],
throwOnError:
true
,
workingDirectory:
workingDirectory
,
);
}
on
ProcessException
catch
(
e
)
{
throwToolExit
(
e
.
message
,
exitCode:
e
.
errorCode
);
}
}
...
...
packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
View file @
069dc9c7
...
...
@@ -186,6 +186,26 @@ void main() {
Platform:
()
=>
fakePlatform
,
});
testUsingContext
(
'git exception during attemptReset throwsToolExit'
,
()
async
{
const
String
revision
=
'abc123'
;
const
String
errorMessage
=
'fatal: Could not parse object ´
$revision
´'
;
when
(
processManager
.
run
(
<
String
>[
'git'
,
'reset'
,
'--hard'
,
revision
]
)).
thenThrow
(
const
ProcessException
(
'git'
,
<
String
>[
'reset'
,
'--hard'
,
revision
],
errorMessage
,
));
expect
(
()
async
=>
await
realCommandRunner
.
attemptReset
(
revision
),
throwsToolExit
(
message:
errorMessage
),
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
});
testUsingContext
(
'flutterUpgradeContinue passes env variables to child process'
,
()
async
{
await
realCommandRunner
.
flutterUpgradeContinue
();
...
...
@@ -315,7 +335,7 @@ class FakeUpgradeCommandRunner extends UpgradeCommandRunner {
Future
<
void
>
upgradeChannel
(
FlutterVersion
flutterVersion
)
async
{}
@override
Future
<
bool
>
attemptReset
(
FlutterVersion
flutterVersion
,
String
newRevision
)
async
=>
alreadyUpToDate
;
Future
<
void
>
attemptReset
(
String
newRevision
)
async
{}
@override
Future
<
void
>
precacheArtifacts
()
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