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
ce1acf5d
Unverified
Commit
ce1acf5d
authored
Nov 19, 2021
by
Christopher Fujino
Committed by
GitHub
Nov 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_conductor] implement requiredLocalBranches (#93580)
parent
b2114efa
Changes
12
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
238 additions
and
985 deletions
+238
-985
cli.dart
dev/conductor/core/bin/cli.dart
+0
-6
conductor_core.dart
dev/conductor/core/lib/conductor_core.dart
+0
-1
git.dart
dev/conductor/core/lib/src/git.dart
+6
-1
globals.dart
dev/conductor/core/lib/src/globals.dart
+2
-1
repository.dart
dev/conductor/core/lib/src/repository.dart
+24
-8
roll_dev.dart
dev/conductor/core/lib/src/roll_dev.dart
+0
-204
start.dart
dev/conductor/core/lib/src/start.dart
+1
-1
codesign_integration_test.dart
dev/conductor/core/test/codesign_integration_test.dart
+19
-4
codesign_test.dart
dev/conductor/core/test/codesign_test.dart
+25
-0
repository_test.dart
dev/conductor/core/test/repository_test.dart
+155
-45
roll_dev_test.dart
dev/conductor/core/test/roll_dev_test.dart
+0
-708
start_test.dart
dev/conductor/core/test/start_test.dart
+6
-6
No files found.
dev/conductor/core/bin/cli.dart
View file @
ce1acf5d
...
...
@@ -46,12 +46,6 @@ Future<void> main(List<String> args) async {
)).
trim
();
<
Command
<
void
>>[
RollDevCommand
(
checkouts:
checkouts
,
fileSystem:
fileSystem
,
platform:
platform
,
stdio:
stdio
,
),
CodesignCommand
(
checkouts:
checkouts
,
flutterRoot:
_localFlutterRoot
,
...
...
dev/conductor/core/lib/conductor_core.dart
View file @
ce1acf5d
...
...
@@ -11,7 +11,6 @@ export 'src/git.dart';
export
'src/globals.dart'
;
export
'src/next.dart'
hide
kStateOption
,
kYesFlag
;
export
'src/repository.dart'
;
export
'src/roll_dev.dart'
;
export
'src/start.dart'
hide
kStateOption
;
export
'src/state.dart'
;
export
'src/status.dart'
hide
kStateOption
;
...
...
dev/conductor/core/lib/src/git.dart
View file @
ce1acf5d
...
...
@@ -33,7 +33,12 @@ class Git {
bool
allowNonZeroExitCode
=
false
,
required
String
workingDirectory
,
})
async
{
final
ProcessResult
result
=
await
_run
(
args
,
workingDirectory
);
late
final
ProcessResult
result
;
try
{
result
=
await
_run
(
args
,
workingDirectory
);
}
on
ProcessException
{
_reportFailureAndExit
(
args
,
workingDirectory
,
result
,
explanation
);
}
if
(
result
.
exitCode
!=
0
&&
!
allowNonZeroExitCode
)
{
_reportFailureAndExit
(
args
,
workingDirectory
,
result
,
explanation
);
}
...
...
dev/conductor/core/lib/src/globals.dart
View file @
ce1acf5d
...
...
@@ -5,6 +5,7 @@
import
'package:args/args.dart'
;
import
'proto/conductor_state.pb.dart'
as
pb
;
import
'repository.dart'
;
const
String
gsutilBinary
=
'gsutil.py'
;
...
...
@@ -15,7 +16,7 @@ const List<String> kReleaseChannels = <String>[
'stable'
,
'beta'
,
'dev'
,
'master'
,
FrameworkRepository
.
defaultBranch
,
];
const
String
kReleaseDocumentationUrl
=
'https://github.com/flutter/flutter/wiki/Flutter-Cherrypick-Process'
;
...
...
dev/conductor/core/lib/src/repository.dart
View file @
ce1acf5d
...
...
@@ -56,17 +56,24 @@ abstract class Repository {
required
this
.
platform
,
required
this
.
fileSystem
,
required
this
.
parentDirectory
,
required
this
.
requiredLocalBranches
,
this
.
initialRef
,
this
.
localUpstream
=
false
,
this
.
previousCheckoutLocation
,
this
.
mirrorRemote
,
})
:
git
=
Git
(
processManager
),
assert
(
localUpstream
!=
null
),
assert
(
upstreamRemote
.
url
.
isNotEmpty
);
final
String
name
;
final
Remote
upstreamRemote
;
/// Branches that must exist locally in this [Repository].
///
/// If this [Repository] is used as a local upstream for another, the
/// downstream may try to fetch these branches, and git will fail if they do
/// not exist.
final
List
<
String
>
requiredLocalBranches
;
/// Remote for user's mirror.
///
/// This value can be null, in which case attempting to access it will lead to
...
...
@@ -117,11 +124,13 @@ abstract class Repository {
workingDirectory:
_checkoutDirectory
!.
path
,
);
}
return
_checkoutDirectory
!;
}
_checkoutDirectory
=
parentDirectory
.
childDirectory
(
name
);
await
lazilyInitialize
(
_checkoutDirectory
!);
return
_checkoutDirectory
!;
}
...
...
@@ -162,7 +171,7 @@ abstract class Repository {
if
(
localUpstream
)
{
// These branches must exist locally for the repo that depends on it
// to fetch and push to.
for
(
final
String
channel
in
kReleaseChannel
s
)
{
for
(
final
String
channel
in
requiredLocalBranche
s
)
{
await
git
.
run
(
<
String
>[
'checkout'
,
channel
,
'--'
],
'check out branch
$channel
locally'
,
...
...
@@ -173,7 +182,7 @@ abstract class Repository {
if
(
initialRef
!=
null
)
{
await
git
.
run
(
<
String
>[
'checkout'
,
'
${upstreamRemote.name}
/
$initialRef
'
],
<
String
>[
'checkout'
,
initialRef
!
],
'Checking out initialRef
$initialRef
'
,
workingDirectory:
checkoutDirectory
.
path
,
);
...
...
@@ -463,8 +472,9 @@ class FrameworkRepository extends Repository {
name:
RemoteName
.
upstream
,
url:
FrameworkRepository
.
defaultUpstream
),
bool
localUpstream
=
false
,
String
?
previousCheckoutLocation
,
String
?
initialRef
,
String
initialRef
=
FrameworkRepository
.
defaultBranch
,
Remote
?
mirrorRemote
,
List
<
String
>?
additionalRequiredLocalBranches
,
})
:
super
(
name:
name
,
upstreamRemote:
upstreamRemote
,
...
...
@@ -477,6 +487,10 @@ class FrameworkRepository extends Repository {
processManager:
checkouts
.
processManager
,
stdio:
checkouts
.
stdio
,
previousCheckoutLocation:
previousCheckoutLocation
,
requiredLocalBranches:
<
String
>[
...?
additionalRequiredLocalBranches
,
...
kReleaseChannels
,
],
);
/// A [FrameworkRepository] with the host conductor's repo set as upstream.
...
...
@@ -487,6 +501,7 @@ class FrameworkRepository extends Repository {
Checkouts
checkouts
,
{
String
name
=
'framework'
,
String
?
previousCheckoutLocation
,
String
initialRef
=
FrameworkRepository
.
defaultBranch
,
required
String
upstreamPath
,
})
{
return
FrameworkRepository
(
...
...
@@ -497,13 +512,12 @@ class FrameworkRepository extends Repository {
url:
'file://
$upstreamPath
/'
,
),
previousCheckoutLocation:
previousCheckoutLocation
,
initialRef:
initialRef
,
);
}
final
Checkouts
checkouts
;
static
const
String
defaultUpstream
=
'git@github.com:flutter/flutter.git'
;
static
const
String
defaultUpstream
=
'git@github.com:flutter/flutter.git'
;
static
const
String
defaultBranch
=
'master'
;
Future
<
CiYaml
>
get
ciYaml
async
{
...
...
@@ -717,6 +731,7 @@ class EngineRepository extends Repository {
bool
localUpstream
=
false
,
String
?
previousCheckoutLocation
,
Remote
?
mirrorRemote
,
List
<
String
>?
additionalRequiredLocalBranches
,
})
:
super
(
name:
name
,
upstreamRemote:
upstreamRemote
,
...
...
@@ -729,6 +744,7 @@ class EngineRepository extends Repository {
processManager:
checkouts
.
processManager
,
stdio:
checkouts
.
stdio
,
previousCheckoutLocation:
previousCheckoutLocation
,
requiredLocalBranches:
additionalRequiredLocalBranches
??
const
<
String
>[],
);
final
Checkouts
checkouts
;
...
...
@@ -739,7 +755,7 @@ class EngineRepository extends Repository {
}
static
const
String
defaultUpstream
=
'git@github.com:flutter/engine.git'
;
static
const
String
defaultBranch
=
'ma
ster
'
;
static
const
String
defaultBranch
=
'ma
in
'
;
/// Update the `dart_revision` entry in the DEPS file.
Future
<
void
>
updateDartRevision
(
...
...
dev/conductor/core/lib/src/roll_dev.dart
deleted
100644 → 0
View file @
b2114efa
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:args/args.dart'
;
import
'package:args/command_runner.dart'
;
import
'package:file/file.dart'
;
import
'package:meta/meta.dart'
;
import
'package:platform/platform.dart'
;
import
'./repository.dart'
;
import
'./stdio.dart'
;
import
'./version.dart'
;
const
String
kIncrement
=
'increment'
;
const
String
kCandidateBranch
=
'candidate-branch'
;
const
String
kRemoteName
=
'remote'
;
const
String
kJustPrint
=
'just-print'
;
const
String
kYes
=
'yes'
;
const
String
kForce
=
'force'
;
const
String
kSkipTagging
=
'skip-tagging'
;
/// Create a new dev release without cherry picks.
class
RollDevCommand
extends
Command
<
void
>
{
RollDevCommand
({
required
this
.
checkouts
,
required
this
.
fileSystem
,
required
this
.
platform
,
required
this
.
stdio
,
})
{
argParser
.
addOption
(
kIncrement
,
help:
'Specifies which part of the x.y.z version number to increment. Required.'
,
valueHelp:
'level'
,
allowed:
<
String
>[
'y'
,
'z'
,
'm'
],
allowedHelp:
<
String
,
String
>{
'y'
:
'Indicates the first dev release after a beta release.'
,
'z'
:
'Indicates a hotfix to a stable release.'
,
'm'
:
'Indicates a standard dev release.'
,
},
);
argParser
.
addOption
(
kCandidateBranch
,
help:
'Specifies which git branch to roll to the dev branch. Required.'
,
valueHelp:
'branch'
,
);
argParser
.
addFlag
(
kForce
,
abbr:
'f'
,
help:
'Force push. Necessary when the previous release had cherry-picks.'
,
negatable:
false
,
);
argParser
.
addFlag
(
kJustPrint
,
negatable:
false
,
help:
"Don't actually roll the dev channel; "
'just print the would-be version and quit.'
,
);
argParser
.
addFlag
(
kSkipTagging
,
negatable:
false
,
help:
'Do not create tag and push to remote, only update release branch. '
'For recovering when the script fails trying to git push to the release branch.'
);
argParser
.
addFlag
(
kYes
,
negatable:
false
,
abbr:
'y'
,
help:
'Skip the confirmation prompt.'
,
);
argParser
.
addOption
(
kRemoteName
,
help:
'Specifies which git remote to fetch from.'
,
defaultsTo:
'upstream'
,
);
}
final
Checkouts
checkouts
;
final
FileSystem
fileSystem
;
final
Platform
platform
;
final
Stdio
stdio
;
@override
String
get
name
=>
'roll-dev'
;
@override
String
get
description
=>
'For publishing a dev release without cherry picks.'
;
@override
Future
<
void
>
run
()
async
{
await
rollDev
(
argResults:
argResults
!,
repository:
FrameworkRepository
(
checkouts
),
stdio:
stdio
,
usage:
argParser
.
usage
,
);
}
}
/// Main script execution.
///
/// Returns true if publishing was successful, else false.
@visibleForTesting
Future
<
bool
>
rollDev
({
required
String
usage
,
required
ArgResults
argResults
,
required
Stdio
stdio
,
required
FrameworkRepository
repository
,
})
async
{
final
String
remoteName
=
argResults
[
kRemoteName
]
as
String
;
final
String
?
level
=
argResults
[
kIncrement
]
as
String
?;
final
String
candidateBranch
=
argResults
[
kCandidateBranch
]
as
String
;
final
bool
justPrint
=
argResults
[
kJustPrint
]
as
bool
;
final
bool
autoApprove
=
argResults
[
kYes
]
as
bool
;
final
bool
force
=
argResults
[
kForce
]
as
bool
;
final
bool
skipTagging
=
argResults
[
kSkipTagging
]
as
bool
;
if
(
level
==
null
||
candidateBranch
==
null
)
{
throw
Exception
(
'roll_dev.dart --
$kIncrement
=level --
$kCandidateBranch
=branch • update the version tags '
'and roll a new dev build.
\n
$usage
'
);
}
final
String
remoteUrl
=
await
repository
.
remoteUrl
(
remoteName
);
if
(!(
await
repository
.
gitCheckoutClean
()))
{
throw
Exception
(
'Your git repository is not clean. Try running "git clean -fd". Warning, '
'this will delete files! Run with -n to find out which ones.'
);
}
await
repository
.
fetch
(
remoteName
);
// Verify [commit] is valid
final
String
commit
=
await
repository
.
reverseParse
(
candidateBranch
);
stdio
.
printStatus
(
'remoteName is
$remoteName
'
);
// Get the name of the last dev release
final
Version
lastVersion
=
Version
.
fromString
(
await
repository
.
getFullTag
(
remoteName
,
'dev'
),
);
final
Version
version
=
skipTagging
?
lastVersion
:
Version
.
fromCandidateBranch
(
candidateBranch
);
final
String
tagName
=
version
.
toString
();
if
((
await
repository
.
reverseParse
(
lastVersion
.
toString
())).
contains
(
commit
.
trim
()))
{
throw
Exception
(
'Commit
$commit
is already on the dev branch as
$lastVersion
.'
);
}
if
(
justPrint
)
{
stdio
.
printStatus
(
tagName
);
return
false
;
}
if
(
skipTagging
&&
!(
await
repository
.
isCommitTagged
(
commit
)))
{
throw
Exception
(
'The
$kSkipTagging
flag is only supported for tagged commits.'
);
}
if
(!
force
&&
!(
await
repository
.
isAncestor
(
commit
,
lastVersion
.
toString
())))
{
throw
Exception
(
'The previous dev tag
$lastVersion
is not a direct ancestor of
$commit
.
\n
'
'The flag "
$kForce
" is required to force push a new release past a cherry-pick.'
);
}
final
String
hash
=
await
repository
.
reverseParse
(
commit
);
// [commit] can be a prefix for [hash].
assert
(
hash
.
startsWith
(
commit
));
// PROMPT
if
(
autoApprove
)
{
stdio
.
printStatus
(
'Publishing Flutter
$version
(
$hash
) to the "dev" channel.'
);
}
else
{
stdio
.
printStatus
(
'Your tree is ready to publish Flutter
$version
'
'(
$hash
) to the "dev" channel.'
);
stdio
.
write
(
'Are you? [yes/no] '
);
if
(
stdio
.
readLineSync
()
!=
'yes'
)
{
stdio
.
printError
(
'The dev roll has been aborted.'
);
return
false
;
}
}
if
(!
skipTagging
)
{
await
repository
.
tag
(
commit
,
version
.
toString
(),
remoteName
);
}
await
repository
.
pushRef
(
fromRef:
commit
,
remote:
remoteName
,
toRef:
'dev'
,
force:
force
,
);
stdio
.
printStatus
(
'Flutter version
$version
has been rolled to the "dev" channel at
$remoteUrl
.'
,
);
return
true
;
}
dev/conductor/core/lib/src/start.dart
View file @
ce1acf5d
...
...
@@ -455,7 +455,7 @@ class StartContext {
}
final
String
branchPoint
=
await
framework
.
branchPoint
(
candidateBranch
,
kFrameworkD
efaultBranch
,
FrameworkRepository
.
d
efaultBranch
,
);
stdio
.
printStatus
(
'Applying the tag
$requestedVersion
at the branch point
$branchPoint
'
);
await
framework
.
tag
(
...
...
dev/conductor/core/test/codesign_integration_test.dart
View file @
ce1acf5d
...
...
@@ -5,7 +5,7 @@
import
'package:args/command_runner.dart'
;
import
'package:conductor_core/src/codesign.dart'
show
CodesignCommand
;
import
'package:conductor_core/src/globals.dart'
;
import
'package:conductor_core/src/repository.dart'
show
Checkouts
;
import
'package:conductor_core/src/repository.dart'
show
Checkouts
,
FrameworkRepository
;
import
'package:file/file.dart'
;
import
'package:file/local.dart'
;
import
'package:platform/platform.dart'
;
...
...
@@ -35,9 +35,24 @@ void main() {
fileSystem
.
file
(
platform
.
executable
),
);
final
CommandRunner
<
void
>
runner
=
CommandRunner
<
void
>(
'codesign-test'
,
''
)
..
addCommand
(
CodesignCommand
(
checkouts:
checkouts
,
flutterRoot:
flutterRoot
));
final
String
currentHead
=
(
processManager
.
runSync
(
<
String
>[
'git'
,
'rev-parse'
,
'HEAD'
],
workingDirectory:
flutterRoot
.
path
,
).
stdout
as
String
).
trim
();
final
FrameworkRepository
framework
=
FrameworkRepository
.
localRepoAsUpstream
(
checkouts
,
upstreamPath:
flutterRoot
.
path
,
initialRef:
currentHead
,
);
final
CommandRunner
<
void
>
runner
=
CommandRunner
<
void
>(
'codesign-test'
,
''
);
runner
.
addCommand
(
CodesignCommand
(
checkouts:
checkouts
,
framework:
framework
,
flutterRoot:
flutterRoot
,
),
);
try
{
await
runner
.
run
(<
String
>[
...
...
dev/conductor/core/test/codesign_test.dart
View file @
ce1acf5d
...
...
@@ -112,6 +112,11 @@ void main() {
'file://
$flutterRoot
/'
,
'
${checkoutsParentDirectory}
flutter_conductor_checkouts/framework'
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
FrameworkRepository
.
defaultBranch
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
...
...
@@ -196,6 +201,11 @@ void main() {
'file://
$flutterRoot
/'
,
'
${checkoutsParentDirectory}
flutter_conductor_checkouts/framework'
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
FrameworkRepository
.
defaultBranch
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
...
...
@@ -284,6 +294,11 @@ void main() {
'file://
$flutterRoot
/'
,
'
${checkoutsParentDirectory}
flutter_conductor_checkouts/framework'
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
FrameworkRepository
.
defaultBranch
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
...
...
@@ -371,6 +386,11 @@ void main() {
'file://
$flutterRoot
/'
,
'
${checkoutsParentDirectory}
flutter_conductor_checkouts/framework'
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
FrameworkRepository
.
defaultBranch
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
...
...
@@ -430,6 +450,11 @@ void main() {
'file://
$flutterRoot
/'
,
'
${checkoutsParentDirectory}
flutter_conductor_checkouts/framework'
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
FrameworkRepository
.
defaultBranch
,
]),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
...
...
dev/conductor/core/test/repository_test.dart
View file @
ce1acf5d
This diff is collapsed.
Click to expand it.
dev/conductor/core/test/roll_dev_test.dart
deleted
100644 → 0
View file @
b2114efa
This diff is collapsed.
Click to expand it.
dev/conductor/core/test/start_test.dart
View file @
ce1acf5d
...
...
@@ -163,7 +163,7 @@ void main() {
command:
<
String
>[
'git'
,
'fetch'
,
'mirror'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
'upstream/
$candidateBranch
'
],
command:
<
String
>[
'git'
,
'checkout'
,
candidateBranch
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'HEAD'
],
...
...
@@ -220,7 +220,7 @@ void main() {
command:
<
String
>[
'git'
,
'fetch'
,
'mirror'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
'upstream/
$candidateBranch
'
],
command:
<
String
>[
'git'
,
'checkout'
,
candidateBranch
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'HEAD'
],
...
...
@@ -348,7 +348,7 @@ void main() {
command:
<
String
>[
'git'
,
'fetch'
,
'mirror'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
'upstream/
$candidateBranch
'
],
command:
<
String
>[
'git'
,
'checkout'
,
candidateBranch
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'HEAD'
],
...
...
@@ -405,7 +405,7 @@ void main() {
command:
<
String
>[
'git'
,
'fetch'
,
'mirror'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
'upstream/
$candidateBranch
'
],
command:
<
String
>[
'git'
,
'checkout'
,
candidateBranch
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'HEAD'
],
...
...
@@ -541,7 +541,7 @@ void main() {
command:
<
String
>[
'git'
,
'fetch'
,
'mirror'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
'upstream/
$candidateBranch
'
],
command:
<
String
>[
'git'
,
'checkout'
,
candidateBranch
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'HEAD'
],
...
...
@@ -598,7 +598,7 @@ void main() {
command:
<
String
>[
'git'
,
'fetch'
,
'mirror'
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'checkout'
,
'upstream/
$candidateBranch
'
],
command:
<
String
>[
'git'
,
'checkout'
,
candidateBranch
],
),
const
FakeCommand
(
command:
<
String
>[
'git'
,
'rev-parse'
,
'HEAD'
],
...
...
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