public function RoboFile::subtreeSplit in Panopoly 7
Does a subtree-split into the individual panopoly_* features' manyrepos.
@command subtree-split
@option $push Push new commits to the manyrepos repos.
1 call to RoboFile::subtreeSplit()
- RoboFile::releasePush in ./
RoboFile.php - Release Stage 2: Pushes commits and tags to the Git remote.
File
- ./
RoboFile.php, line 376
Class
- RoboFile
- This is project's console commands configuration for Robo task runner.
Code
public function subtreeSplit($opts = [
'push' => FALSE,
]) {
$branch = static::PANOPOLY_DEFAULT_BRANCH;
if ($this
->getCurrentBranch() !== $branch) {
throw new \Exception("Only run this command on the {$branch} branch");
}
/** @var \Robo\Collection\CollectionBuilder|$this $collection */
$collection = $this
->collectionBuilder();
// Get a list of panopoly_* features with panopoly_demo removed.
$panopoly_features_names = $this
->getPanopolyFeaturesNames();
unset($panopoly_features_names['panopoly_demo']);
$panopoly_features = array_keys($panopoly_features_names);
foreach ($panopoly_features as $panopoly_feature) {
$collection
->addCode(function () use ($panopoly_feature) {
$this
->say("Fetching from individual repo for {$panopoly_feature}...");
});
// Run this way to allow failure, and hide the messages normally.
$collection
->addCode(function () use ($panopoly_feature) {
$this
->taskExec("git remote add {$panopoly_feature} git@git.drupal.org:project/{$panopoly_feature}.git")
->setVerbosityThreshold(VerbosityThresholdInterface::VERBOSITY_DEBUG)
->run();
});
$collection
->taskExec("git fetch {$panopoly_feature} --no-tags");
}
$collection
->completion($this
->taskExec("git checkout {$branch}"));
foreach ($panopoly_features as $panopoly_feature) {
$collection
->addCode(function () use ($panopoly_feature) {
$this
->say("Performing subtree split for {$panopoly_feature}...");
});
$collection
->taskExecStack()
->exec("splitsh-lite --prefix=modules/panopoly/{$panopoly_feature} --target=refs/heads/{$panopoly_feature}-{$branch}")
->exec("git checkout {$panopoly_feature}-{$branch}")
->exec("git branch --set-upstream-to {$panopoly_feature}/{$branch}");
if (isset($this->SUBTREE_MERGE_COMMITS[$panopoly_feature])) {
# TODO: This works, but generates the wrong commit hashes for some reason!
#if ! git branch --contains ${MERGE_COMMITS[$repo]} >/dev/null 2>&1; then
# echo "Injecting the merge commit..."
# git rebase ${MERGE_COMMITS[$repo]} || die "Unable to inject the merge commit for $repo"
#fi
# This scares me, but the hashes come out OK...
$collection
->taskExec("git pull {$panopoly_feature} {$branch} --rebase");
}
$collection
->taskExec("git checkout {$branch}");
}
if ($opts['push']) {
foreach ($panopoly_features as $panopoly_feature) {
$collection
->addCode(function () use ($panopoly_feature) {
$this
->say("Pushing {$panopoly_feature}...");
});
$collection
->taskExecStack()
->exec("git checkout {$panopoly_feature}-{$branch}")
->exec("git push {$panopoly_feature} {$panopoly_feature}-{$branch}:{$branch}");
}
}
return $collection;
}