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
316d4498
Unverified
Commit
316d4498
authored
Apr 10, 2019
by
Jonah Williams
Committed by
GitHub
Apr 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
warn on uncomitted changes (#30235)
parent
f66ee3e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
0 deletions
+49
-0
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+23
-0
upgrade_test.dart
packages/flutter_tools/test/commands/upgrade_test.dart
+26
-0
No files found.
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
316d4498
...
...
@@ -72,6 +72,17 @@ class UpgradeCommandRunner {
);
}
}
// If there are uncomitted changes we might be on the right commit but
// we should still warn.
if
(!
force
&&
await
hasUncomittedChanges
())
{
throwToolExit
(
'Your flutter checkout has local changes that would be erased by '
'upgrading. If you want to keep these changes, it is recommended that '
'you stash them via "git stash" or else commit the changes to a local '
'branch. If it is okay to remove local changes, then re-run this '
'command with --force.'
);
}
await
resetChanges
(
gitTagVersion
);
await
upgradeChannel
(
flutterVersion
);
await
attemptFastForward
();
...
...
@@ -81,6 +92,18 @@ class UpgradeCommandRunner {
return
null
;
}
Future
<
bool
>
hasUncomittedChanges
()
async
{
try
{
final
RunResult
result
=
await
runCheckedAsync
(<
String
>[
'git'
,
'status'
,
'-s'
],
workingDirectory:
Cache
.
flutterRoot
);
return
result
.
stdout
.
trim
().
isNotEmpty
;
}
catch
(
e
)
{
throwToolExit
(
'git status failed:
$e
'
);
}
return
false
;
}
/// Check if there is an upstream repository configured.
///
/// Exits tool if there is no upstream.
...
...
packages/flutter_tools/test/commands/upgrade_test.dart
View file @
316d4498
...
...
@@ -29,6 +29,7 @@ void main() {
fakeCommandRunner
=
FakeUpgradeCommandRunner
();
realCommandRunner
=
UpgradeCommandRunner
();
processManager
=
MockProcessManager
();
fakeCommandRunner
.
willHaveUncomittedChanges
=
false
;
});
test
(
'throws on unknown tag, official branch, noforce'
,
()
async
{
...
...
@@ -49,6 +50,26 @@ void main() {
expect
(
await
result
,
null
);
});
test
(
'throws tool exit with uncommited changes'
,
()
async
{
fakeCommandRunner
.
willHaveUncomittedChanges
=
true
;
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
false
,
gitTagVersion
,
flutterVersion
,
);
expect
(
result
,
throwsA
(
isA
<
ToolExit
>()));
});
test
(
'does not throw tool exit with uncommited changes and force'
,
()
async
{
fakeCommandRunner
.
willHaveUncomittedChanges
=
true
;
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
true
,
gitTagVersion
,
flutterVersion
,
);
expect
(
await
result
,
null
);
});
test
(
'Doesn
\'
t throw on known tag, dev branch, no force'
,
()
async
{
final
Future
<
FlutterCommandResult
>
result
=
fakeCommandRunner
.
runCommand
(
false
,
...
...
@@ -127,9 +148,14 @@ void main() {
}
class
FakeUpgradeCommandRunner
extends
UpgradeCommandRunner
{
bool
willHaveUncomittedChanges
=
false
;
@override
Future
<
void
>
verifyUpstreamConfigured
()
async
{}
@override
Future
<
bool
>
hasUncomittedChanges
()
async
=>
willHaveUncomittedChanges
;
@override
Future
<
void
>
resetChanges
(
GitTagVersion
gitTagVersion
)
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