protected function execute(InputInterface $input, OutputInterface $output)
{
$this->validateInput($input);
$selectedEnvironment = $this->getSelectedEnvironment();
$environmentId = $selectedEnvironment->id;
if (!$selectedEnvironment->operationAvailable('merge')) {
$this->stdErr->writeln("Operation not available: The environment <error>{$environmentId}</error> can't be merged.");
return 1;
}
$parentId = $selectedEnvironment->parent;
$confirmText = "Are you sure you want to merge <info>{$environmentId}</info> with its parent, <info>{$parentId}</info>?";
if (!$this->getHelper('question')->confirm($confirmText)) {
return 1;
}
$this->stdErr->writeln("Merging <info>{$environmentId}</info> with <info>{$parentId}</info>");
$this->api()->clearEnvironmentsCache($selectedEnvironment->project);
$activity = $selectedEnvironment->merge();
if (!$input->getOption('no-wait')) {
$success = ActivityUtil::waitAndLog($activity, $this->stdErr, 'Merge complete', 'Merge failed');
if (!$success) {
return 1;
}
}
return 0;
}