Skip to content

Commit 8519e9f

Browse files
committed
[FEATURE] ✨ Add merge to batch mode
Add merge subcommand to batch mode. Refs #22
1 parent ab2a69f commit 8519e9f

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

src/RoboFile.php

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ class RoboFile extends \Robo\Tasks
1919
*
2020
* @param array $options
2121
* @option $repository-url URI of Git repository (HTTPS/SSH/FILE)
22-
* @option $working-directory Working directory to checkout repositories
22+
* @option $working-directory Working directory to check out repositories
2323
* @option $patch-source-directory Source directory for all collected patches
2424
* @option $patch-name Name of the directory where the patch code resides
2525
* @option $source-branch Name of the branch to create a new branch upon
2626
* @option $branch-name Name of the feature branch to be created
27-
* @option $halt-before-commit Pause before changes are commited, asks to continue
27+
* @option $halt-before-commit Pause before changes are committed, asks to continue
2828
* @return int exit code
2929
* @throws TaskException
3030
*/
@@ -84,9 +84,9 @@ public function patch(array $options = [
8484
*
8585
* @param array $options
8686
* @option $repository-url URI of Git repository (HTTPS/SSH/FILE)
87-
* @option $working-directory Working directory to checkout repositories
88-
* @option $source Source branch name (eg. feature branch)
89-
* @option $target Target branch name (eg. main branch)
87+
* @option $working-directory Working directory to check out repositories
88+
* @option $source Source branch name (e.g. feature branch)
89+
* @option $target Target branch name (e.g. main branch)
9090
* @return int exit code
9191
* @throws TaskException
9292
*/
@@ -184,11 +184,12 @@ public function create(array $options = [
184184
*
185185
* @param string $batchCommand Name of command to run in batch mode (patch or merge, default: patch)
186186
* @param array $options
187-
* @option $working-directory Working directory to checkout repositories
187+
* @option $working-directory Working directory to check out repositories
188188
* @option $patch-source-directory Source directory for all collected patches
189189
* @option $patch-name Name of the directory where the patch code resides
190190
* @option $branch-name Name of the feature branch to be created
191-
* @option $halt-before-commit Pause before changes are commited, asks to continue
191+
* @option $halt-before-commit Pause before changes are committed, asks to continue
192+
* @option $source Source branch name (e.g. feature branch)
192193
* @return int exit code
193194
* @throws TaskException
194195
*/
@@ -198,6 +199,7 @@ public function batch(string $batchCommand, array $options = [
198199
'patch-name|p' => 'template',
199200
'branch-name' => null,
200201
'halt-before-commit' => false,
202+
'source' => null
201203
]): int
202204
{
203205
$workingDirectory = getcwd();
@@ -214,18 +216,32 @@ public function batch(string $batchCommand, array $options = [
214216
});
215217
array_shift($repositories); // remove column header
216218

217-
foreach ($repositories as $repository) {
218-
/** @noinspection DisconnectedForeachInstructionInspection */
219-
chdir($workingDirectory); // reset working directory
220-
$this->patch([
221-
'repository-url' => $repository[0],
222-
'working-directory' => $options['working-directory'],
223-
'patch-source-directory' => $options['patch-source-directory'],
224-
'patch-name' => $options['patch-name'],
225-
'source-branch' => $repository[1],
226-
'branch-name' => $options['branch-name'],
227-
'halt-before-commit' => $options['halt-before-commit'],
228-
]);
219+
if ($batchCommand === 'patch') {
220+
foreach ($repositories as $repository) {
221+
/** @noinspection DisconnectedForeachInstructionInspection */
222+
chdir($workingDirectory); // reset working directory
223+
$this->patch([
224+
'repository-url' => $repository[0],
225+
'working-directory' => $options['working-directory'],
226+
'patch-source-directory' => $options['patch-source-directory'],
227+
'patch-name' => $options['patch-name'],
228+
'source-branch' => $repository[1],
229+
'branch-name' => $options['branch-name'],
230+
'halt-before-commit' => $options['halt-before-commit'],
231+
]);
232+
}
233+
}
234+
if ($batchCommand === 'merge') {
235+
foreach ($repositories as $repository) {
236+
/** @noinspection DisconnectedForeachInstructionInspection */
237+
chdir($workingDirectory); // reset working directory
238+
$this->merge([
239+
'repository-url' => $repository[0],
240+
'working-directory' => $options['working-directory'],
241+
'source' => $options['source'],
242+
'target' => $repository[1],
243+
]);
244+
}
229245
}
230246

231247
return 0;

0 commit comments

Comments
 (0)