mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
WIP Commits separated as follows: - Update lints in analysis_options files - Run `dart fix --apply` - Clean up leftover analysis issues - Run `dart format .` in the right places. Local analysis and testing passes. Checking CI now. Part of https://github.com/flutter/flutter/issues/178827 - Adoption of flutter_lints in examples/api coming in a separate change (cc @loic-sharma) ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
161 lines
5.9 KiB
Dart
161 lines
5.9 KiB
Dart
// 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:file/memory.dart';
|
|
import 'package:packages_autoroller/src/repository.dart';
|
|
import 'package:platform/platform.dart';
|
|
|
|
import 'common.dart';
|
|
|
|
void main() {
|
|
group('repository', () {
|
|
late FakePlatform platform;
|
|
const rootDir = '/';
|
|
const revision = 'deadbeef';
|
|
late MemoryFileSystem fileSystem;
|
|
late FakeProcessManager processManager;
|
|
late TestStdio stdio;
|
|
|
|
setUp(() {
|
|
final String pathSeparator = const LocalPlatform().pathSeparator;
|
|
fileSystem = MemoryFileSystem.test();
|
|
platform = FakePlatform(
|
|
environment: <String, String>{
|
|
'HOME': <String>['path', 'to', 'home'].join(pathSeparator),
|
|
},
|
|
pathSeparator: pathSeparator,
|
|
);
|
|
processManager = FakeProcessManager.empty();
|
|
stdio = TestStdio();
|
|
});
|
|
|
|
test('commit() throws if there are no local changes to commit and addFirst = true', () {
|
|
const commit1 = 'abc123';
|
|
const commit2 = 'def456';
|
|
const message = 'This is a commit message.';
|
|
processManager.addCommands(<FakeCommand>[
|
|
FakeCommand(
|
|
command: <String>[
|
|
'git',
|
|
'clone',
|
|
'--origin',
|
|
'upstream',
|
|
'--',
|
|
FrameworkRepository.defaultUpstream,
|
|
fileSystem.path.join(rootDir, 'package_autoroller_checkouts', 'framework'),
|
|
],
|
|
),
|
|
const FakeCommand(command: <String>['git', 'remote', 'add', 'mirror', 'mirror']),
|
|
const FakeCommand(command: <String>['git', 'fetch', 'mirror']),
|
|
const FakeCommand(command: <String>['git', 'checkout', FrameworkRepository.defaultBranch]),
|
|
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit1),
|
|
const FakeCommand(command: <String>['git', 'status', '--porcelain']),
|
|
const FakeCommand(command: <String>['git', 'commit', '--message', message]),
|
|
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit2),
|
|
]);
|
|
|
|
final checkouts = Checkouts(
|
|
parentDirectory: fileSystem.directory(rootDir),
|
|
platform: platform,
|
|
processManager: processManager,
|
|
stdio: stdio,
|
|
);
|
|
|
|
final repo = FrameworkRepository(checkouts, mirrorRemote: const Remote.mirror('mirror'));
|
|
expect(
|
|
() async => repo.commit(message, addFirst: true),
|
|
throwsExceptionWith('Tried to commit with message $message but no changes were present'),
|
|
);
|
|
});
|
|
|
|
test('commit() passes correct commit message', () async {
|
|
const commit1 = 'abc123';
|
|
const commit2 = 'def456';
|
|
const message = 'This is a commit message.';
|
|
processManager.addCommands(<FakeCommand>[
|
|
FakeCommand(
|
|
command: <String>[
|
|
'git',
|
|
'clone',
|
|
'--origin',
|
|
'upstream',
|
|
'--',
|
|
FrameworkRepository.defaultUpstream,
|
|
fileSystem.path.join(rootDir, 'package_autoroller_checkouts', 'framework'),
|
|
],
|
|
),
|
|
const FakeCommand(command: <String>['git', 'remote', 'add', 'mirror', 'mirror']),
|
|
const FakeCommand(command: <String>['git', 'fetch', 'mirror']),
|
|
const FakeCommand(command: <String>['git', 'checkout', FrameworkRepository.defaultBranch]),
|
|
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit1),
|
|
const FakeCommand(command: <String>['git', 'commit', '--message', message]),
|
|
const FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: commit2),
|
|
]);
|
|
|
|
final checkouts = Checkouts(
|
|
parentDirectory: fileSystem.directory(rootDir),
|
|
platform: platform,
|
|
processManager: processManager,
|
|
stdio: stdio,
|
|
);
|
|
|
|
final repo = FrameworkRepository(checkouts, mirrorRemote: const Remote.mirror('mirror'));
|
|
await repo.commit(message);
|
|
expect(processManager.hasRemainingExpectations, false);
|
|
});
|
|
|
|
test('.listRemoteBranches() parses git output', () async {
|
|
const remoteName = 'mirror';
|
|
const lsRemoteOutput = '''
|
|
Extraneous debug information that should be ignored.
|
|
|
|
4d44dca340603e25d4918c6ef070821181202e69 refs/heads/experiment
|
|
35185330c6af3a435f615ee8ac2fed8b8bb7d9d4 refs/heads/feature-a
|
|
6f60a1e7b2f3d2c2460c9dc20fe54d0e9654b131 refs/heads/feature-b
|
|
c1436c42c0f3f98808ae767e390c3407787f1a67 refs/heads/fix_bug_1234
|
|
bbbcae73699263764ad4421a4b2ca3952a6f96cb refs/heads/stable
|
|
|
|
Extraneous debug information that should be ignored.
|
|
''';
|
|
processManager.addCommands(const <FakeCommand>[
|
|
FakeCommand(
|
|
command: <String>[
|
|
'git',
|
|
'clone',
|
|
'--origin',
|
|
'upstream',
|
|
'--',
|
|
FrameworkRepository.defaultUpstream,
|
|
'${rootDir}package_autoroller_checkouts/framework',
|
|
],
|
|
),
|
|
FakeCommand(command: <String>['git', 'remote', 'add', 'mirror', 'mirror']),
|
|
FakeCommand(command: <String>['git', 'fetch', 'mirror']),
|
|
FakeCommand(command: <String>['git', 'checkout', 'master']),
|
|
FakeCommand(command: <String>['git', 'rev-parse', 'HEAD'], stdout: revision),
|
|
FakeCommand(
|
|
command: <String>['git', 'ls-remote', '--heads', remoteName],
|
|
stdout: lsRemoteOutput,
|
|
),
|
|
]);
|
|
final checkouts = Checkouts(
|
|
parentDirectory: fileSystem.directory(rootDir),
|
|
platform: platform,
|
|
processManager: processManager,
|
|
stdio: stdio,
|
|
);
|
|
|
|
final Repository repo = FrameworkRepository(
|
|
checkouts,
|
|
mirrorRemote: const Remote.mirror('mirror'),
|
|
);
|
|
final List<String> branchNames = await repo.listRemoteBranches(remoteName);
|
|
expect(
|
|
branchNames,
|
|
equals(<String>['experiment', 'feature-a', 'feature-b', 'fix_bug_1234', 'stable']),
|
|
);
|
|
});
|
|
});
|
|
}
|