From d7fbb0a4a4cdbc4d7303e7a5486c1e2e7c01ddba Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 21 Sep 2019 09:26:15 +0200 Subject: [PATCH] [travis] honor .gitattributes when building local packages --- .github/build-packages.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/build-packages.php b/.github/build-packages.php index 5e9bcc1415..1f59c35276 100644 --- a/.github/build-packages.php +++ b/.github/build-packages.php @@ -17,6 +17,7 @@ $mergeBase = trim(shell_exec(sprintf('git merge-base "%s" HEAD', array_shift($di $packages = array(); $flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE; +$preferredInstall = json_decode(file_get_contents(__DIR__.'/composer-config.json'), true)['config']['preferred-install']; foreach ($dirs as $k => $dir) { if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) { @@ -42,7 +43,12 @@ foreach ($dirs as $k => $dir) { $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); file_put_contents($dir.'/composer.json', $json); } - passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *"); + + if (isset($preferredInstall[$package->name]) && 'source' === $preferredInstall[$package->name]) { + passthru("cd $dir && tar -cf package.tar --exclude='package.tar' *"); + } else { + passthru("cd $dir && git init && git add . && git commit -m - && git archive -o package.tar HEAD && rm .git/ -Rf"); + } if (!isset($package->extra->{'branch-alias'}->{'dev-master'})) { echo "Missing \"dev-master\" branch-alias in composer.json extra.\n";