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
a2f5364d
Unverified
Commit
a2f5364d
authored
May 14, 2020
by
Christopher Fujino
Committed by
GitHub
May 14, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
throw more specific toolexit when git fails during upgrade (#57162)
parent
7706a97a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
7 deletions
+72
-7
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+17
-6
upgrade_test.dart
...ter_tools/test/commands.shard/permeable/upgrade_test.dart
+55
-1
No files found.
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
a2f5364d
...
...
@@ -219,12 +219,23 @@ class UpgradeCommandRunner {
workingDirectory:
workingDirectory
,
);
revision
=
result
.
stdout
.
trim
();
}
on
Exception
{
throwToolExit
(
'Unable to upgrade Flutter: no origin repository configured. '
"Run 'git remote add origin "
"https://github.com/flutter/flutter' in
$workingDirectory
"
,
);
}
on
Exception
catch
(
e
)
{
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'
);
}
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
'
);
}
else
{
throwToolExit
(
errorString
);
}
}
return
revision
;
}
...
...
packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
View file @
a2f5364d
...
...
@@ -160,7 +160,7 @@ void main() {
Platform:
()
=>
fakePlatform
,
});
testUsingContext
(
'fetchRemoteRevision'
,
()
async
{
testUsingContext
(
'fetchRemoteRevision
returns revision if git succeeds
'
,
()
async
{
const
String
revision
=
'abc123'
;
when
(
processManager
.
run
(
<
String
>[
'git'
,
'fetch'
,
'--tags'
],
...
...
@@ -185,6 +185,60 @@ void main() {
Platform:
()
=>
fakePlatform
,
});
testUsingContext
(
'fetchRemoteRevision throws toolExit if HEAD is detached'
,
()
async
{
when
(
processManager
.
run
(
<
String
>[
'git'
,
'fetch'
,
'--tags'
],
environment:
anyNamed
(
'environment'
),
workingDirectory:
anyNamed
(
'workingDirectory'
)),
).
thenAnswer
((
Invocation
invocation
)
async
{
return
FakeProcessResult
()..
exitCode
=
0
;
});
when
(
processManager
.
run
(
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u}'
],
environment:
anyNamed
(
'environment'
),
workingDirectory:
anyNamed
(
'workingDirectory'
)),
).
thenThrow
(
const
ProcessException
(
'git'
,
<
String
>[
'rev-parse'
,
'--verify'
,
'@{u}'
],
'fatal: HEAD does not point to a branch'
,
));
expect
(
()
async
=>
await
realCommandRunner
.
fetchRemoteRevision
(),
throwsToolExit
(
message:
'You are not currently on a release branch.'
),
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
});
testUsingContext
(
'fetchRemoteRevision throws toolExit if no upstream configured'
,
()
async
{
when
(
processManager
.
run
(
<
String
>[
'git'
,
'fetch'
,
'--tags'
],
environment:
anyNamed
(
'environment'
),
workingDirectory:
anyNamed
(
'workingDirectory'
)),
).
thenAnswer
((
Invocation
invocation
)
async
{
return
FakeProcessResult
()..
exitCode
=
0
;
});
when
(
processManager
.
run
(
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u}'
],
environment:
anyNamed
(
'environment'
),
workingDirectory:
anyNamed
(
'workingDirectory'
)),
).
thenThrow
(
const
ProcessException
(
'git'
,
<
String
>[
'rev-parse'
,
'--verify'
,
'@{u}'
],
'fatal: no upstream configured for branch'
,
));
expect
(
()
async
=>
await
realCommandRunner
.
fetchRemoteRevision
(),
throwsToolExit
(
message:
'Unable to upgrade Flutter: no origin repository configured
\
.'
,
),
);
},
overrides:
<
Type
,
Generator
>{
ProcessManager:
()
=>
processManager
,
Platform:
()
=>
fakePlatform
,
});
testUsingContext
(
'git exception during attemptReset throwsToolExit'
,
()
async
{
const
String
revision
=
'abc123'
;
const
String
errorMessage
=
'fatal: Could not parse object ´
$revision
´'
;
...
...
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