Skip to content

Commit

Permalink
False positives and conflicts list for shells
Browse files Browse the repository at this point in the history
This will fix shell naming conflicts between plugins
  • Loading branch information
luke83 committed Nov 9, 2016
1 parent cfdf2b7 commit e6b9afd
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/Console/ShellDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public function addShortPluginAliases()
$io->setLoggers(false);
$list = $task->getShellList() + ['app' => []];
$fixed = array_flip($list['app']) + array_flip($list['CORE']);
$aliases = [];
$aliases = $others = [];

foreach ($plugins as $plugin) {
if (!isset($list[$plugin])) {
Expand All @@ -253,6 +253,11 @@ public function addShortPluginAliases()

foreach ($list[$plugin] as $shell) {
$aliases += [$shell => $plugin];
if (!isset($others[$shell])) {
$others[$shell] = [$plugin];
} else {
$others[$shell] = array_merge($others[$shell], [$plugin]);
}
}
}

Expand All @@ -269,12 +274,26 @@ public function addShortPluginAliases()
$other = static::alias($shell);
if ($other) {
$other = $aliases[$shell];
Log::write(
'debug',
"command '$shell' in plugin '$plugin' was not aliased, conflicts with '$other'",
['shell-dispatcher']
);
continue;
if ($other != $plugin) {
Log::write(
'debug',
"command '$shell' in plugin '$plugin' was not aliased, conflicts with '$other'",
['shell-dispatcher']
);
continue;
}
}

if (isset($others[$shell])) {
$conflicts = array_diff($others[$shell], [$plugin]);
if (count($conflicts) > 0) {
$conflictList = implode("', '", $conflicts);
Log::write(
'debug',
"command '$shell' in plugin '$plugin' was not aliased, conflicts with '$conflictList'",
['shell-dispatcher']
);
}
}

static::alias($shell, "$plugin.$shell");
Expand Down

0 comments on commit e6b9afd

Please sign in to comment.