This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/.github/travis.php

55 lines
1.7 KiB
PHP
Raw Normal View History

2015-07-21 14:40:18 +01:00
<?php
if (4 > $_SERVER['argc']) {
2016-06-30 07:29:00 +01:00
echo "Usage: branch version dir1 dir2 ... dirN\n";
2015-07-21 14:40:18 +01:00
exit(1);
}
2016-06-30 10:22:01 +01:00
chdir(dirname(__DIR__));
2015-07-21 14:40:18 +01:00
$dirs = $_SERVER['argv'];
array_shift($dirs);
$branch = array_shift($dirs);
2016-06-30 07:29:00 +01:00
$version = array_shift($dirs);
2015-07-21 14:40:18 +01:00
$packages = array();
$flags = PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
foreach ($dirs as $dir) {
2016-06-30 07:29:00 +01:00
if (!system("git diff --name-only $branch...HEAD -- $dir", $exitStatus)) {
if ($exitStatus) {
exit($exitStatus);
}
2015-07-21 14:40:18 +01:00
continue;
}
echo "$dir\n";
$json = ltrim(file_get_contents($dir.'/composer.json'));
if (null === $package = json_decode($json)) {
passthru("composer validate $dir/composer.json");
exit(1);
}
2015-07-21 14:40:18 +01:00
$package->repositories = array(array(
'type' => 'composer',
2016-06-30 10:22:01 +01:00
'url' => 'file://'.dirname(__DIR__).'/',
2015-07-21 14:40:18 +01:00
));
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
file_put_contents($dir.'/composer.json', $json);
2015-07-21 14:40:18 +01:00
passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *");
$package->version = 'master' !== $version ? $version.'.999' : 'dev-master';
2015-07-21 14:40:18 +01:00
$package->dist['type'] = 'tar';
2016-06-30 10:22:01 +01:00
$package->dist['url'] = 'file://'.dirname(__DIR__)."/$dir/package.tar";
2015-07-21 14:40:18 +01:00
$packages[$package->name][$package->version] = $package;
2016-01-18 14:59:30 +00:00
$versions = @file_get_contents('https://packagist.org/packages/'.$package->name.'.json') ?: '{"package":{"versions":[]}}';
2015-07-21 14:40:18 +01:00
$versions = json_decode($versions);
2016-07-01 15:56:05 +01:00
foreach ($versions->package->versions as $v => $package) {
$packages[$package->name] += array($v => $package);
2015-07-21 14:40:18 +01:00
}
}
file_put_contents('packages.json', json_encode(compact('packages'), $flags));