Skip to content

Commit b410884

Browse files
committed
add tests
1 parent c567216 commit b410884

File tree

2 files changed

+192
-111
lines changed

2 files changed

+192
-111
lines changed

script/tool/lib/src/branch_for_batch_release_command.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class BranchForBatchReleaseCommand extends PackageCommand {
8080

8181
print('Creating and pushing release branch...');
8282
await _pushBranch(
83-
repository: repository,
83+
git: repository,
8484
package: package,
8585
branchName: branchName,
8686
pendingChangelogFiles: pendingChangelogs.files,
@@ -153,15 +153,15 @@ class BranchForBatchReleaseCommand extends PackageCommand {
153153
}
154154

155155
Future<void> _pushBranch({
156-
required GitDir repository,
156+
required GitDir git,
157157
required RepositoryPackage package,
158158
required String branchName,
159159
required List<File> pendingChangelogFiles,
160160
required ReleaseInfo releaseInfo,
161161
}) async {
162162
print(' Creating new branch "$branchName"...');
163163
final io.ProcessResult checkoutResult =
164-
await repository.runCommand(<String>['checkout', '-b', branchName]);
164+
await git.runCommand(<String>['checkout', '-b', branchName]);
165165
if (checkoutResult.exitCode != 0) {
166166
printError(
167167
'Failed to create branch $branchName: ${checkoutResult.stderr}');
@@ -195,23 +195,23 @@ class BranchForBatchReleaseCommand extends PackageCommand {
195195
print(' Removing pending changelog files...');
196196
for (final File file in pendingChangelogFiles) {
197197
final io.ProcessResult rmResult =
198-
await repository.runCommand(<String>['rm', file.path]);
198+
await git.runCommand(<String>['rm', file.path]);
199199
if (rmResult.exitCode != 0) {
200200
printError('Failed to rm ${file.path}: ${rmResult.stderr}');
201201
throw ToolExit(_kGitFailedToPush);
202202
}
203203
}
204204

205205
print(' Staging changes...');
206-
final io.ProcessResult addResult = await repository.runCommand(
206+
final io.ProcessResult addResult = await git.runCommand(
207207
<String>['add', package.pubspecFile.path, package.changelogFile.path]);
208208
if (addResult.exitCode != 0) {
209209
printError('Failed to git add: ${addResult.stderr}');
210210
throw ToolExit(_kGitFailedToPush);
211211
}
212212

213213
print(' Committing changes...');
214-
final io.ProcessResult commitResult = await repository.runCommand(<String>[
214+
final io.ProcessResult commitResult = await git.runCommand(<String>[
215215
'commit',
216216
'-m',
217217
'${package.displayName}: Prepare for release'
@@ -222,8 +222,8 @@ class BranchForBatchReleaseCommand extends PackageCommand {
222222
}
223223

224224
print(' Pushing to remote...');
225-
final io.ProcessResult pushResult = await repository
226-
.runCommand(<String>['push', 'origin', branchName, '--force']);
225+
final io.ProcessResult pushResult =
226+
await git.runCommand(<String>['push', 'origin', branchName]);
227227
if (pushResult.exitCode != 0) {
228228
printError('Failed to push to $branchName: ${pushResult.stderr}');
229229
throw ToolExit(_kGitFailedToPush);

0 commit comments

Comments
 (0)