1
0
Fork 0

Merge remote-tracking branch 'origin/1.10'

pull/8780/head
Jordi Boggiano 2020-04-13 12:41:30 +02:00
commit 876136022b
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
3 changed files with 79 additions and 17 deletions

View File

@ -65,20 +65,37 @@ EOT
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
// init repos
$composer = $this->getComposer();
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
$composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
// Dispatch pre-status-command
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
$exitCode = $this->doExecute($input, $output);
// Dispatch post-status-command
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
return $exitCode;
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
private function doExecute(InputInterface $input, OutputInterface $output)
{
// init repos
$composer = $this->getComposer();
$installedRepo = $composer->getRepositoryManager()->getLocalRepository();
$dm = $composer->getDownloadManager();
$im = $composer->getInstallationManager();
// Dispatch pre-status-command
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
$errors = array();
$io = $this->getIO();
$unpushedChanges = array();
@ -206,9 +223,6 @@ EOT
$io->writeError('Use --verbose (-v) to see a list of files');
}
// Dispatch post-status-command
$composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
}
}

View File

@ -374,8 +374,8 @@ class ValidatingArrayLoader implements LoaderInterface
return;
}
if (!preg_match('{^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9]([_.-]?[a-z0-9]+)*$}iD', $name)) {
return $name.' is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9]([_.-]?[a-z0-9]+)*".';
if (!preg_match('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
return $name.' is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$".';
}
$reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');

View File

@ -173,6 +173,26 @@ class ValidatingArrayLoaderTest extends TestCase
'bin' => 'bin1',
),
),
array( // package name with dashes
array(
'name' => 'foo/bar-baz',
),
),
array( // package name with dashes
array(
'name' => 'foo/bar--baz',
),
),
array( // package name with dashes
array(
'name' => 'foo/b-ar--ba-z',
),
),
array( // package name with dashes
array(
'name' => 'npm-asset/angular--core',
),
),
);
}
@ -232,15 +252,24 @@ class ValidatingArrayLoaderTest extends TestCase
public function errorProvider()
{
return array(
array(
$invalidNames = array(
'foo',
'foo/-bar-',
'foo/-bar',
);
$invalidNaming = array();
foreach($invalidNames as $invalidName) {
$invalidNaming[] = array(
array(
'name' => 'foo',
'name' => $invalidName,
),
array(
'name : invalid value (foo), must match [A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*',
"name : invalid value ($invalidName), must match [A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*",
),
),
);
}
return array_merge($invalidNaming, array(
array(
array(
'name' => 'foo/bar',
@ -292,12 +321,31 @@ class ValidatingArrayLoaderTest extends TestCase
'transport-options : should be an array, string given',
),
),
);
));
}
public function warningProvider()
{
return array(
$invalidNames = array(
'fo--oo/bar',
'fo-oo/bar__baz',
'fo-oo/bar_.baz',
'foo/bar---baz',
);
$invalidNaming = array();
foreach($invalidNames as $invalidName) {
$invalidNaming[] = array(
array(
'name' => $invalidName,
),
array(
"Deprecation warning: Your package name $invalidName is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match \"^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$\". Make sure you fix this as Composer 2.0 will error.",
),
false,
);
}
return array_merge($invalidNaming, array(
array(
array(
'name' => 'foo/bar',
@ -420,6 +468,6 @@ class ValidatingArrayLoaderTest extends TestCase
),
false,
),
);
));
}
}