mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
apply cherrypicks (#81936)
This commit is contained in:
parent
6b2f3bc113
commit
a5318173fe
@ -317,8 +317,8 @@ abstract class Repository {
|
||||
);
|
||||
|
||||
git.run(
|
||||
<String>['cherry-pick', '--no-commit', commit],
|
||||
'attempt to cherry-pick $commit without committing',
|
||||
<String>['cherry-pick', commit],
|
||||
'cherry-pick $commit',
|
||||
workingDirectory: checkoutDirectory.path,
|
||||
);
|
||||
}
|
||||
|
@ -216,7 +216,10 @@ class StartCommand extends Command<void> {
|
||||
stdio.printTrace(
|
||||
'Attempt to cherrypick $revision ${success ? 'succeeded' : 'failed'}',
|
||||
);
|
||||
if (!success) {
|
||||
if (success) {
|
||||
engine.cherryPick(revision);
|
||||
cherrypick.state = pb.CherrypickState.COMPLETED;
|
||||
} else {
|
||||
cherrypick.state = pb.CherrypickState.PENDING_WITH_CONFLICT;
|
||||
}
|
||||
}
|
||||
@ -253,10 +256,16 @@ class StartCommand extends Command<void> {
|
||||
|
||||
for (final pb.Cherrypick cherrypick in frameworkCherrypicks) {
|
||||
final String revision = cherrypick.trunkRevision;
|
||||
final bool result = framework.canCherryPick(revision);
|
||||
final bool success = framework.canCherryPick(revision);
|
||||
stdio.printTrace(
|
||||
'Attempt to cherrypick $cherrypick ${result ? 'succeeded' : 'failed'}',
|
||||
'Attempt to cherrypick $cherrypick ${success ? 'succeeded' : 'failed'}',
|
||||
);
|
||||
if (success) {
|
||||
framework.cherryPick(revision);
|
||||
cherrypick.state = pb.CherrypickState.COMPLETED;
|
||||
} else {
|
||||
cherrypick.state = pb.CherrypickState.PENDING_WITH_CONFLICT;
|
||||
}
|
||||
}
|
||||
|
||||
final String frameworkHead = framework.reverseParse('HEAD');
|
||||
|
172
dev/tools/test/repository_test.dart
Normal file
172
dev/tools/test/repository_test.dart
Normal file
@ -0,0 +1,172 @@
|
||||
// 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:dev_tools/repository.dart';
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:platform/platform.dart';
|
||||
|
||||
import '../../../packages/flutter_tools/test/src/fake_process_manager.dart';
|
||||
|
||||
import './common.dart';
|
||||
|
||||
void main() {
|
||||
group('repository', () {
|
||||
test('canCherryPick returns true if git cherry-pick returns 0', () {
|
||||
const LocalPlatform platform = LocalPlatform();
|
||||
const String rootDir = '/';
|
||||
const String commit = 'abc123';
|
||||
|
||||
final TestStdio stdio = TestStdio();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final FakeProcessManager processManager =
|
||||
FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
fileSystem.path
|
||||
.join(rootDir, 'flutter_conductor_checkouts', 'framework'),
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'cherry-pick',
|
||||
'--no-commit',
|
||||
commit,
|
||||
], exitCode: 0),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'reset',
|
||||
'HEAD',
|
||||
'--hard',
|
||||
]),
|
||||
]);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
final Repository repository = FrameworkRepository(checkouts);
|
||||
expect(repository.canCherryPick(commit), true);
|
||||
});
|
||||
|
||||
test('canCherryPick returns false if git cherry-pick returns non-zero', () {
|
||||
const LocalPlatform platform = LocalPlatform();
|
||||
const String rootDir = '/';
|
||||
const String commit = 'abc123';
|
||||
|
||||
final TestStdio stdio = TestStdio();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final FakeProcessManager processManager =
|
||||
FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
fileSystem.path
|
||||
.join(rootDir, 'flutter_conductor_checkouts', 'framework'),
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'cherry-pick',
|
||||
'--no-commit',
|
||||
commit,
|
||||
], exitCode: 1),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'diff',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'reset',
|
||||
'HEAD',
|
||||
'--hard',
|
||||
]),
|
||||
]);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
final Repository repository = FrameworkRepository(checkouts);
|
||||
expect(repository.canCherryPick(commit), false);
|
||||
});
|
||||
|
||||
test('cherryPick() applies the commit', () {
|
||||
const LocalPlatform platform = LocalPlatform();
|
||||
const String rootDir = '/';
|
||||
const String commit = 'abc123';
|
||||
|
||||
final TestStdio stdio = TestStdio();
|
||||
final MemoryFileSystem fileSystem = MemoryFileSystem.test();
|
||||
final FakeProcessManager processManager =
|
||||
FakeProcessManager.list(<FakeCommand>[
|
||||
FakeCommand(command: <String>[
|
||||
'git',
|
||||
'clone',
|
||||
'--origin',
|
||||
'upstream',
|
||||
'--',
|
||||
FrameworkRepository.defaultUpstream,
|
||||
fileSystem.path
|
||||
.join(rootDir, 'flutter_conductor_checkouts', 'framework'),
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'rev-parse',
|
||||
'HEAD',
|
||||
], stdout: commit),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'status',
|
||||
'--porcelain',
|
||||
]),
|
||||
const FakeCommand(command: <String>[
|
||||
'git',
|
||||
'cherry-pick',
|
||||
commit,
|
||||
]),
|
||||
]);
|
||||
final Checkouts checkouts = Checkouts(
|
||||
fileSystem: fileSystem,
|
||||
parentDirectory: fileSystem.directory(rootDir),
|
||||
platform: platform,
|
||||
processManager: processManager,
|
||||
stdio: stdio,
|
||||
);
|
||||
final Repository repository = FrameworkRepository(checkouts);
|
||||
repository.cherryPick(commit);
|
||||
expect(processManager.hasRemainingExpectations, false);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user