mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 09:12:51 +01:00
Improve select on tasks
This commit is contained in:
parent
e227623ba6
commit
83022a3927
@ -82,7 +82,8 @@ class Master
|
||||
}
|
||||
|
||||
if ($task->isLocal()) {
|
||||
$plannedHosts = [new Localhost('localhost')];
|
||||
// Special name for local() tasks.
|
||||
$plannedHosts = [new Localhost('local')];
|
||||
}
|
||||
|
||||
if ($limit === 1 || count($plannedHosts) === 1) {
|
||||
@ -106,10 +107,9 @@ class Master
|
||||
}
|
||||
} else {
|
||||
foreach (array_chunk($hosts, $limit) as $chunk) {
|
||||
$selector = $task->getSelector();
|
||||
$selectedHosts = [];
|
||||
foreach ($chunk as $currentHost) {
|
||||
if ($selector === null || Selector::apply($selector, $currentHost)) {
|
||||
if (Selector::apply($task->getSelector(), $currentHost)) {
|
||||
$selectedHosts[] = $currentHost;
|
||||
}
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ class Planner
|
||||
*/
|
||||
public function commit(array $hosts, Task $task)
|
||||
{
|
||||
if (count($hosts) === 1 && $hosts[0]->getAlias() === 'localhost') {
|
||||
if (count($hosts) === 1 && $hosts[0]->getAlias() === 'local') {
|
||||
$row = [];
|
||||
foreach ($this->template as $alias) {
|
||||
$row[] = "-";
|
||||
}
|
||||
$row[] = $task->getName() . " (local)";
|
||||
$row[] = $task->getName();
|
||||
$this->table->addRow($row);
|
||||
return;
|
||||
}
|
||||
|
@ -39,6 +39,10 @@ class Selector
|
||||
|
||||
public static function apply($conditions, Host $host)
|
||||
{
|
||||
if (empty($conditions)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$labels = $host->get('labels', []);
|
||||
$labels['__host__'] = $host->getAlias();
|
||||
$labels['__all__'] = 'yes';
|
||||
|
@ -83,7 +83,7 @@ class Task
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->callback = $callback;
|
||||
$this->selector = Selector::parse('all');
|
||||
$this->selector = null;
|
||||
}
|
||||
|
||||
public function run(Context $context)
|
||||
|
Loading…
x
Reference in New Issue
Block a user