Commit e9fc0f1a authored by catch's avatar catch

Issue #2664274 by alexpott, bojanz, fortis, Mile23, arknoll, Barryvdh:...

Issue #2664274 by alexpott, bojanz, fortis, Mile23, arknoll, Barryvdh: Combination of --prefer-dist and .gitattributes confuses our vendor test cleanup
parent 920edd9d
...@@ -149,6 +149,7 @@ public static function ensureHtaccess(Event $event) { ...@@ -149,6 +149,7 @@ public static function ensureHtaccess(Event $event) {
*/ */
public static function vendorTestCodeCleanup(PackageEvent $event) { public static function vendorTestCodeCleanup(PackageEvent $event) {
$vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir'); $vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir');
$io = $event->getIO();
$op = $event->getOperation(); $op = $event->getOperation();
if ($op->getJobType() == 'update') { if ($op->getJobType() == 'update') {
$package = $op->getTargetPackage(); $package = $op->getTargetPackage();
...@@ -157,14 +158,39 @@ public static function vendorTestCodeCleanup(PackageEvent $event) { ...@@ -157,14 +158,39 @@ public static function vendorTestCodeCleanup(PackageEvent $event) {
$package = $op->getPackage(); $package = $op->getPackage();
} }
$package_key = static::findPackageKey($package->getName()); $package_key = static::findPackageKey($package->getName());
$message = sprintf(" Processing <comment>%s</comment>", $package->getPrettyName());
if ($io->isVeryVerbose()) {
$io->write($message);
}
if ($package_key) { if ($package_key) {
foreach (static::$packageToCleanup[$package_key] as $path) { foreach (static::$packageToCleanup[$package_key] as $path) {
$dir_to_remove = $vendor_dir . '/' . $package_key . '/' . $path; $dir_to_remove = $vendor_dir . '/' . $package_key . '/' . $path;
$print_message = $io->isVeryVerbose();
if (is_dir($dir_to_remove)) { if (is_dir($dir_to_remove)) {
if (!static::deleteRecursive($dir_to_remove)) { if (static::deleteRecursive($dir_to_remove)) {
throw new \RuntimeException(sprintf("Failure removing directory '%s' in package '%s'.", $path, $package->getPrettyName())); $message = sprintf(" <info>Removing directory '%s'</info>", $path);
}
else {
// Always display a message if this fails as it means something has
// gone wrong. Therefore the message has to include the package name
// as the first informational message might not exist.
$print_message = TRUE;
$message = sprintf(" <error>Failure removing directory '%s'</error> in package <comment>%s</comment>.", $path, $package->getPrettyName());
} }
} }
else {
// If the package has changed or the --prefer-dist version does not
// include the directory this is not an error.
$message = sprintf(" Directory '%s' does not exist", $path);
}
if ($print_message) {
$io->write($message);
}
}
if ($io->isVeryVerbose()) {
// Add a new line to separate this output from the next package.
$io->write("");
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment