Skip to content

Commit 5919688

Browse files
author
kovacs.ferenc
committed
forwardport PR#110
1 parent bbbd447 commit 5919688

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/Composer/Satis/Command/BuildCommand.php

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected function configure()
5353
new InputArgument('file', InputArgument::OPTIONAL, 'Json file to use', './satis.json'),
5454
new InputArgument('output-dir', InputArgument::OPTIONAL, 'Location where to output built files', null),
5555
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be built, if not provided all packages are.', null),
56+
new InputOption('repository-url', null, InputOption::VALUE_OPTIONAL, 'Only update the repository at given url', null),
5657
new InputOption('no-html-output', null, InputOption::VALUE_NONE, 'Turn off HTML view'),
5758
new InputOption('skip-errors', null, InputOption::VALUE_NONE, 'Skip Download or Archive errors'),
5859
))
@@ -148,8 +149,36 @@ protected function execute(InputInterface $input, OutputInterface $output)
148149
throw new \InvalidArgumentException('The output dir must be specified as second argument or be configured inside '.$input->getArgument('file'));
149150
}
150151

151-
$composer = $this->getApplication()->getComposer(true, $config);
152-
$packages = $this->selectPackages($composer, $output, $verbose, $requireAll, $requireDependencies, $requireDevDependencies, $minimumStability, $skipErrors, $packagesFilter);
152+
if (($singleRepositoryUrl = $input->getOption('repository-url')) !== null
153+
&& FALSE !== ($otherPackagesCache = @file_get_contents($outputDir.'/packages.cache')))
154+
{
155+
$otherPackages = unserialize($otherPackagesCache);
156+
157+
// find repository configuration
158+
$singleRepositoryConfig = null;
159+
foreach ($config['repositories'] as $r) {
160+
if ($r['url'] == $singleRepositoryUrl) {
161+
$singleRepositoryConfig = $r;
162+
break;
163+
}
164+
}
165+
if ($singleRepositoryConfig === null) {
166+
throw new \InvalidArgumentException('Requested repository not found in configuration: '.$singleRepositoryUrl);
167+
}
168+
169+
// use only selected repository
170+
$config['repositories'] = array($singleRepositoryConfig);
171+
172+
$composer = $this->getApplication()->getComposer(true, $config);
173+
$packages = $this->selectPackages($composer, $output, $verbose, $requireAll, $requireDependencies, $requireDevDependencies, $minimumStability, $skipErrors, $packagesFilter);
174+
175+
// merge with cached data
176+
$packages = array_merge($otherPackages, $packages);
177+
ksort($packages, SORT_STRING);
178+
} else {
179+
$composer = $this->getApplication()->getComposer(true, $config);
180+
$packages = $this->selectPackages($composer, $output, $verbose, $requireAll, $requireDependencies, $requireDevDependencies, $minimumStability, $skipErrors, $packagesFilter);
181+
}
153182

154183
if ($htmlView = !$input->getOption('no-html-output')) {
155184
$htmlView = !isset($config['output-html']) || $config['output-html'];
@@ -159,6 +188,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
159188
$this->dumpDownloads($config, $packages, $input, $output, $outputDir, $skipErrors);
160189
}
161190

191+
file_put_contents($outputDir.'/packages.cache', serialize($packages));
192+
162193
$filenamePrefix = $outputDir.'/include/all';
163194
$filename = $outputDir.'/packages.json';
164195
if(!empty($packagesFilter)) {

0 commit comments

Comments
 (0)