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
ae805de4
Unverified
Commit
ae805de4
authored
Apr 14, 2022
by
Anurag Roy
Committed by
GitHub
Apr 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tools] Remove usage of globals.flutterGit from version (#100744)
parent
fe11f57c
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
87 deletions
+62
-87
upgrade.dart
packages/flutter_tools/lib/src/commands/upgrade.dart
+3
-3
globals.dart
packages/flutter_tools/lib/src/globals.dart
+0
-3
version.dart
packages/flutter_tools/lib/src/version.dart
+28
-49
upgrade_test.dart
...tter_tools/test/commands.shard/hermetic/upgrade_test.dart
+1
-1
upgrade_test.dart
...ter_tools/test/commands.shard/permeable/upgrade_test.dart
+5
-5
version_test.dart
packages/flutter_tools/test/general.shard/version_test.dart
+25
-26
No files found.
packages/flutter_tools/lib/src/commands/upgrade.dart
View file @
ae805de4
...
...
@@ -75,7 +75,7 @@ class UpgradeCommand extends FlutterCommand {
force:
boolArg
(
'force'
),
continueFlow:
boolArg
(
'continue'
),
testFlow:
stringArg
(
'working-directory'
)
!=
null
,
gitTagVersion:
GitTagVersion
.
determine
(
globals
.
processUtils
),
gitTagVersion:
GitTagVersion
.
determine
(
globals
.
processUtils
,
globals
.
platform
),
flutterVersion:
stringArg
(
'working-directory'
)
==
null
?
globals
.
flutterVersion
:
FlutterVersion
(
workingDirectory:
_commandRunner
.
workingDirectory
),
...
...
@@ -243,9 +243,9 @@ class UpgradeCommandRunner {
throwOnError:
true
,
workingDirectory:
workingDirectory
,
);
//
'@{u}' means upstream HEAD
//
Get the latest commit revision of the upstream
final
RunResult
result
=
await
globals
.
processUtils
.
run
(
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u}'
],
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
kGitTrackingUpstream
],
throwOnError:
true
,
workingDirectory:
workingDirectory
,
);
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
ae805de4
...
...
@@ -46,9 +46,6 @@ import 'reporting/reporting.dart';
import
'runner/local_engine.dart'
;
import
'version.dart'
;
/// The flutter GitHub repository.
String
get
flutterGit
=>
platform
.
environment
[
'FLUTTER_GIT_URL'
]
??
'https://github.com/flutter/flutter.git'
;
Artifacts
?
get
artifacts
=>
context
.
get
<
Artifacts
>();
BuildSystem
get
buildSystem
=>
context
.
get
<
BuildSystem
>()!;
Cache
get
cache
=>
context
.
get
<
Cache
>()!;
...
...
packages/flutter_tools/lib/src/version.dart
View file @
ae805de4
...
...
@@ -17,6 +17,11 @@ import 'globals.dart' as globals;
const
String
_unknownFrameworkVersion
=
'0.0.0-unknown'
;
/// A git shortcut for the branch that is being tracked by the current one.
///
/// See `man gitrevisions` for more information.
const
String
kGitTrackingUpstream
=
'@{upstream}'
;
/// This maps old branch names to the names of branches that replaced them.
///
/// For example, in 2021 we deprecated the "dev" channel and transitioned "dev"
...
...
@@ -75,7 +80,7 @@ class FlutterVersion {
globals
.
processUtils
,
_workingDirectory
,
);
_gitTagVersion
=
GitTagVersion
.
determine
(
globals
.
processUtils
,
workingDirectory:
_workingDirectory
,
gitRef:
_frameworkRevision
);
_gitTagVersion
=
GitTagVersion
.
determine
(
globals
.
processUtils
,
globals
.
platform
,
workingDirectory:
_workingDirectory
,
gitRef:
_frameworkRevision
);
_frameworkVersion
=
gitTagVersion
.
frameworkVersionFor
(
_frameworkRevision
);
}
...
...
@@ -89,7 +94,7 @@ class FlutterVersion {
/// user explicitly wants to get the version, e.g. for `flutter --version` or
/// `flutter doctor`.
void
fetchTagsAndUpdate
()
{
_gitTagVersion
=
GitTagVersion
.
determine
(
globals
.
processUtils
,
workingDirectory:
_workingDirectory
,
fetchTags:
true
);
_gitTagVersion
=
GitTagVersion
.
determine
(
globals
.
processUtils
,
globals
.
platform
,
workingDirectory:
_workingDirectory
,
fetchTags:
true
);
_frameworkVersion
=
gitTagVersion
.
frameworkVersionFor
(
_frameworkRevision
);
}
...
...
@@ -106,7 +111,7 @@ class FlutterVersion {
String
?
channel
=
_channel
;
if
(
channel
==
null
)
{
final
String
gitChannel
=
_runGit
(
'git rev-parse --abbrev-ref --symbolic
@{u}
'
,
'git rev-parse --abbrev-ref --symbolic
$kGitTrackingUpstream
'
,
globals
.
processUtils
,
_workingDirectory
,
);
...
...
@@ -195,19 +200,19 @@ class FlutterVersion {
/// A date String describing the last framework commit.
///
/// If a git command fails, this will return a placeholder date.
String
get
frameworkCommitDate
=>
_
latestG
itCommitDate
(
lenient:
true
);
String
get
frameworkCommitDate
=>
_
g
itCommitDate
(
lenient:
true
);
// The date of the
latest commit on the given branch. If no branch is
//
specified, then it is
the current local branch.
// The date of the
given commit hash as [gitRef]. If no hash is specified,
//
then it is the HEAD of
the current local branch.
//
// If lenient is true, and the git command fails, a placeholder date is
// returned. Otherwise, the VersionCheckError exception is propagated.
static
String
_
latestG
itCommitDate
({
String
?
branch
,
static
String
_
g
itCommitDate
({
String
gitRef
=
'HEAD'
,
bool
lenient
=
false
,
})
{
final
List
<
String
>
args
=
gitLog
(<
String
>[
if
(
branch
!=
null
)
branch
,
gitRef
,
'-n'
,
'1'
,
'--pretty=format:%ad'
,
...
...
@@ -247,7 +252,7 @@ class FlutterVersion {
DateTime
localFrameworkCommitDate
;
try
{
// Don't perform the update check if fetching the latest local commit failed.
localFrameworkCommitDate
=
DateTime
.
parse
(
_
latestG
itCommitDate
());
localFrameworkCommitDate
=
DateTime
.
parse
(
_
g
itCommitDate
());
}
on
VersionCheckError
{
return
;
}
...
...
@@ -264,51 +269,18 @@ class FlutterVersion {
).
run
();
}
/// The name of the temporary git remote used to check for the latest
/// available Flutter framework version.
///
/// In the absence of bugs and crashes a Flutter developer should never see
/// this remote appear in their `git remote` list, but also if it happens to
/// persist we do the proper clean-up for extra robustness.
static
const
String
_versionCheckRemote
=
'__flutter_version_check__'
;
/// The date of the latest framework commit in the remote repository.
///
/// Throws [VersionCheckError] if a git command fails, for example, when the
/// remote git repository is not reachable due to a network issue.
static
Future
<
String
>
fetchRemoteFrameworkCommitDate
(
String
branch
)
async
{
await
_removeVersionCheckRemoteIfExists
();
try
{
await
_run
(<
String
>[
'git'
,
'remote'
,
'add'
,
_versionCheckRemote
,
globals
.
flutterGit
,
]);
await
_run
(<
String
>[
'git'
,
'fetch'
,
_versionCheckRemote
,
branch
]);
return
_latestGitCommitDate
(
branch:
'
$_versionCheckRemote
/
$branch
'
,
);
// Fetch upstream branch's commit and tags
await
_run
(<
String
>[
'git'
,
'fetch'
,
'--tags'
]);
return
_gitCommitDate
(
gitRef:
kGitTrackingUpstream
);
}
on
VersionCheckError
catch
(
error
)
{
if
(
globals
.
platform
.
environment
.
containsKey
(
'FLUTTER_GIT_URL'
))
{
globals
.
printWarning
(
'Warning: the Flutter git upstream was overridden '
'by the environment variable FLUTTER_GIT_URL =
${globals.flutterGit}
'
);
}
globals
.
printError
(
error
.
toString
());
globals
.
printError
(
error
.
message
);
rethrow
;
}
finally
{
await
_removeVersionCheckRemoteIfExists
();
}
}
static
Future
<
void
>
_removeVersionCheckRemoteIfExists
()
async
{
final
List
<
String
>
remotes
=
(
await
_run
(<
String
>[
'git'
,
'remote'
]))
.
split
(
'
\n
'
)
.
map
<
String
>((
String
name
)
=>
name
.
trim
())
// to account for OS-specific line-breaks
.
toList
();
if
(
remotes
.
contains
(
_versionCheckRemote
))
{
await
_run
(<
String
>[
'git'
,
'remote'
,
'remove'
,
_versionCheckRemote
]);
}
}
...
...
@@ -728,13 +700,20 @@ class GitTagVersion {
/// The git tag that is this version's closest ancestor.
final
String
?
gitTag
;
static
GitTagVersion
determine
(
ProcessUtils
processUtils
,
{
String
?
workingDirectory
,
bool
fetchTags
=
false
,
String
gitRef
=
'HEAD'
})
{
static
GitTagVersion
determine
(
ProcessUtils
processUtils
,
Platform
platform
,
{
String
?
workingDirectory
,
bool
fetchTags
=
false
,
String
gitRef
=
'HEAD'
})
{
if
(
fetchTags
)
{
final
String
channel
=
_runGit
(
'git rev-parse --abbrev-ref HEAD'
,
processUtils
,
workingDirectory
);
if
(
channel
==
'dev'
||
channel
==
'beta'
||
channel
==
'stable'
)
{
globals
.
printTrace
(
'Skipping request to fetchTags - on well known channel
$channel
.'
);
}
else
{
_runGit
(
'git fetch
${globals.flutterGit}
--tags -f'
,
processUtils
,
workingDirectory
);
final
String
flutterGit
=
platform
.
environment
[
'FLUTTER_GIT_URL'
]
??
'https://github.com/flutter/flutter.git'
;
_runGit
(
'git fetch
$flutterGit
--tags -f'
,
processUtils
,
workingDirectory
);
}
}
// find all tags attached to the given [gitRef]
...
...
packages/flutter_tools/test/commands.shard/hermetic/upgrade_test.dart
View file @
ae805de4
...
...
@@ -63,7 +63,7 @@ void main() {
command:
<
String
>[
'git'
,
'fetch'
,
'--tags'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u}'
],
command:
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u
pstream
}'
],
stdout:
upstreamHeadRevision
,
),
const
FakeCommand
(
...
...
packages/flutter_tools/test/commands.shard/permeable/upgrade_test.dart
View file @
ae805de4
...
...
@@ -160,7 +160,7 @@ void main() {
'git'
,
'fetch'
,
'--tags'
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u}'
,
'git'
,
'rev-parse'
,
'--verify'
,
'@{u
pstream
}'
,
],
stdout:
revision
),
const
FakeCommand
(
command:
<
String
>[
...
...
@@ -188,10 +188,10 @@ void main() {
'git'
,
'fetch'
,
'--tags'
]),
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u}'
],
command:
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u
pstream
}'
],
exception:
ProcessException
(
'git'
,
<
String
>[
'rev-parse'
,
'--verify'
,
'@{u}'
],
<
String
>[
'rev-parse'
,
'--verify'
,
'@{u
pstream
}'
],
'fatal: HEAD does not point to a branch'
,
),
),
...
...
@@ -217,10 +217,10 @@ void main() {
'git'
,
'fetch'
,
'--tags'
]),
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u}'
],
command:
<
String
>[
'git'
,
'rev-parse'
,
'--verify'
,
'@{u
pstream
}'
],
exception:
ProcessException
(
'git'
,
<
String
>[
'rev-parse'
,
'--verify'
,
'@{u}'
],
<
String
>[
'rev-parse'
,
'--verify'
,
'@{u
pstream
}'
],
'fatal: no upstream configured for branch'
,
),
),
...
...
packages/flutter_tools/test/general.shard/version_test.dart
View file @
ae805de4
...
...
@@ -70,7 +70,7 @@ void main() {
stdout:
'0.1.2-3-1234abcd'
,
),
FakeCommand
(
command:
const
<
String
>[
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'--symbolic'
,
'@{u}'
],
command:
const
<
String
>[
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'--symbolic'
,
'@{u
pstream
}'
],
stdout:
'origin/
$channel
'
,
),
const
FakeCommand
(
...
...
@@ -78,31 +78,22 @@ void main() {
stdout:
flutterUpstreamUrl
,
),
FakeCommand
(
command:
const
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'-n'
,
'1'
,
'--pretty=format:%ad'
,
'--date=iso'
],
command:
const
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'
HEAD'
,
'
-n'
,
'1'
,
'--pretty=format:%ad'
,
'--date=iso'
],
stdout:
getChannelUpToDateVersion
().
toString
(),
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'remote'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'remote'
,
'add'
,
'__flutter_version_check__'
,
flutterUpstreamUrl
],
command:
<
String
>[
'git'
,
'fetch'
,
'--tags'
],
),
FakeCommand
(
command:
<
String
>[
'git'
,
'fetch'
,
'__flutter_version_check__'
,
channel
],
),
FakeCommand
(
command:
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'__flutter_version_check__/
$channel
'
,
'-n'
,
'1'
,
'--pretty=format:%ad'
,
'--date=iso'
],
command:
const
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'@{upstream}'
,
'-n'
,
'1'
,
'--pretty=format:%ad'
,
'--date=iso'
],
stdout:
getChannelOutOfDateVersion
().
toString
(),
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'remote'
],
),
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'
],
command:
const
<
String
>[
'git'
,
'-c'
,
'log.showSignature=false'
,
'log'
,
'
HEAD'
,
'
-n'
,
'1'
,
'--pretty=format:%ad'
,
'--date=iso'
],
stdout:
getChannelUpToDateVersion
().
toString
(),
),
FakeCommand
(
...
...
@@ -114,6 +105,7 @@ void main() {
final
FlutterVersion
flutterVersion
=
globals
.
flutterVersion
;
await
flutterVersion
.
checkFlutterVersionFreshness
();
expect
(
flutterVersion
.
channel
,
channel
);
expect
(
flutterVersion
.
repositoryUrl
,
flutterUpstreamUrl
);
expect
(
flutterVersion
.
frameworkRevision
,
'1234abcd'
);
expect
(
flutterVersion
.
frameworkRevisionShort
,
'1234abcd'
);
expect
(
flutterVersion
.
frameworkVersion
,
'0.0.0-unknown'
);
...
...
@@ -423,7 +415,7 @@ void main() {
stdout:
'0.1.2-3-1234abcd'
,
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'--symbolic'
,
'@{u}'
],
command:
<
String
>[
'git'
,
'rev-parse'
,
'--abbrev-ref'
,
'--symbolic'
,
'@{u
pstream
}'
],
stdout:
'feature-branch'
,
),
const
FakeCommand
(
...
...
@@ -526,7 +518,8 @@ void main() {
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
);
final
FakePlatform
platform
=
FakePlatform
();
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
platform
,
workingDirectory:
'.'
);
expect
(
gitTagVersion
.
frameworkVersionFor
(
'abcd1234'
),
stableTag
);
});
...
...
@@ -545,7 +538,9 @@ void main() {
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
);
final
FakePlatform
platform
=
FakePlatform
();
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
platform
,
workingDirectory:
'.'
);
expect
(
gitTagVersion
.
frameworkVersionFor
(
'abcd1234'
),
stableTag
);
});
...
...
@@ -569,7 +564,9 @@ void main() {
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
);
final
FakePlatform
platform
=
FakePlatform
();
final
GitTagVersion
gitTagVersion
=
GitTagVersion
.
determine
(
processUtils
,
platform
,
workingDirectory:
'.'
);
// reported version should increment the y
expect
(
gitTagVersion
.
frameworkVersionFor
(
headRevision
),
'1.3.0-0.0.pre.12'
);
});
...
...
@@ -588,8 +585,9 @@ void main() {
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
FakePlatform
platform
=
FakePlatform
();
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
);
GitTagVersion
.
determine
(
processUtils
,
platform
,
workingDirectory:
'.'
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
});
...
...
@@ -611,8 +609,9 @@ void main() {
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
FakePlatform
platform
=
FakePlatform
();
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
,
fetchTags:
true
);
GitTagVersion
.
determine
(
processUtils
,
platform
,
workingDirectory:
'.'
,
fetchTags:
true
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
});
...
...
@@ -637,8 +636,9 @@ void main() {
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
FakePlatform
platform
=
FakePlatform
();
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
,
fetchTags:
true
);
GitTagVersion
.
determine
(
processUtils
,
platform
,
workingDirectory:
'.'
,
fetchTags:
true
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
});
...
...
@@ -663,13 +663,12 @@ void main() {
processManager:
fakeProcessManager
,
logger:
BufferLogger
.
test
(),
);
final
FakePlatform
platform
=
FakePlatform
(
environment:
<
String
,
String
>
{
'FLUTTER_GIT_URL'
:
'https://githubmirror.com/flutter.git'
},
);
GitTagVersion
.
determine
(
processUtils
,
workingDirectory:
'.'
,
fetchTags:
true
);
GitTagVersion
.
determine
(
processUtils
,
platform
,
workingDirectory:
'.'
,
fetchTags:
true
);
expect
(
fakeProcessManager
,
hasNoRemainingExpectations
);
},
overrides:
<
Type
,
Generator
>{
Platform:
()
=>
FakePlatform
(
environment:
<
String
,
String
>{
'FLUTTER_GIT_URL'
:
'https://githubmirror.com/flutter.git'
,
}),
});
}
...
...
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