From 1f081383799a777e4c9b13e623d7b66120242398 Mon Sep 17 00:00:00 2001 From: arai Date: Sun, 16 Feb 2020 13:34:08 +0900 Subject: [PATCH 1/5] Delete variable --- src/Composer/DependencyResolver/Solver.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Composer/DependencyResolver/Solver.php b/src/Composer/DependencyResolver/Solver.php index dbfafd243..a046a7a92 100644 --- a/src/Composer/DependencyResolver/Solver.php +++ b/src/Composer/DependencyResolver/Solver.php @@ -679,7 +679,6 @@ class Solver */ $decisionQueue = array(); - $decisionSupplementQueue = array(); /** * @todo this makes $disableRules always false; determine the rationale and possibly remove dead code? */ @@ -687,7 +686,6 @@ class Solver $level = 1; $systemLevel = $level + 1; - $installedPos = 0; while (true) { if (1 === $level) { From 36a83869ed117a1d24719dc23ea838623900bf34 Mon Sep 17 00:00:00 2001 From: Yohann Durand <34881241+Yohann76@users.noreply.github.com> Date: Sun, 16 Feb 2020 23:02:38 +0100 Subject: [PATCH 2/5] Update 02-libraries.md --- doc/02-libraries.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/02-libraries.md b/doc/02-libraries.md index e59f505dd..c02756e50 100644 --- a/doc/02-libraries.md +++ b/doc/02-libraries.md @@ -54,7 +54,7 @@ file: ### VCS Versioning Composer uses your VCS's branch and tag features to resolve the version -constraints you specify in your `require` field to specific sets of files. +constraints you specify in your [`require`](04-schema.md#require) field to specific sets of files. When determining valid available versions, Composer looks at all of your tags and branches and translates their names into an internal list of options that it then matches against the version constraint you provided. From c4f19e51d843533c88d3e3ded92bc00f4f966560 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 28 Feb 2020 09:09:23 +0100 Subject: [PATCH 3/5] Rework the funding info parsing to avoid requiring graphql permissions --- src/Composer/Repository/Vcs/GitHubDriver.php | 87 +++++++++++++++----- 1 file changed, 68 insertions(+), 19 deletions(-) diff --git a/src/Composer/Repository/Vcs/GitHubDriver.php b/src/Composer/Repository/Vcs/GitHubDriver.php index 58afe605d..8194b196d 100644 --- a/src/Composer/Repository/Vcs/GitHubDriver.php +++ b/src/Composer/Repository/Vcs/GitHubDriver.php @@ -167,7 +167,6 @@ class GitHubDriver extends VcsDriver if (!isset($composer['abandoned']) && $this->isArchived) { $composer['abandoned'] = true; } - if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) { $composer['funding'] = $funding; } @@ -193,28 +192,78 @@ class GitHubDriver extends VcsDriver return $this->fundingInfo = false; } - $graphql = 'query{repository(owner:"'.$this->owner.'",name:"'.$this->repository.'"){fundingLinks{platform,url}}}'; - try { - $result = $this->remoteFilesystem->getContents($this->originUrl, 'https://api.github.com/graphql', false, array( - 'http' => array( - 'method' => 'POST', - 'content' => json_encode(array('query' => $graphql)), - 'header' => array('Content-Type: application/json'), - ), - 'retry-auth-failure' => false, - )); - } catch (TransportException $e) { - return $this->fundingInfo = false; - } - $result = json_decode($result, true); + foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) { - if (empty($result['data']['repository']['fundingLinks'])) { + try { + $result = $this->remoteFilesystem->getContents($this->originUrl, $file, false, array( + 'retry-auth-failure' => false, + )); + $response = json_decode($result, true); + } catch (TransportException $e) { + continue; + } + if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) { + continue; + } + } + if (empty($funding)) { return $this->fundingInfo = false; } - return $this->fundingInfo = array_map(function ($link) { - return array('type' => strtolower($link['platform']), 'url' => $link['url']); - }, $result['data']['repository']['fundingLinks']); + $result = array(); + $key = null; + foreach (preg_split('{\r?\n}', $funding) as $line) { + $line = preg_replace('{#.*}', '', $line); + $line = trim($line); + if (preg_match('{^(\w+)\s*:\s*(.+)$}', $line, $match)) { + if (preg_match('{^\[.*\]$}', $match[2])) { + foreach (array_map('trim', preg_split('{[\'"]?\s*,\s*[\'"]?}', substr($match[2], 1, -1))) as $item) { + $result[] = array('type' => $match[1], 'url' => trim($item, '"\'')); + } + } else { + $result[] = array('type' => $match[1], 'url' => $match[2]); + } + $key = null; + } elseif (preg_match('{^(\w+)\s*:$}', $line, $match)) { + $key = $match[1]; + } elseif ($key && preg_match('{^-\s*(.+)$}', $line, $match)) { + $result[] = array('type' => $key, 'url' => $match[1]); + } + } + + foreach ($result as $key => $item) { + switch ($item['type']) { + case 'tidelift': + $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url']; + break; + case 'github': + $result[$key]['url'] = 'https://github.com/' . basename($item['url']); + break; + case 'patreon': + $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']); + break; + case 'otechie': + $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']); + break; + case 'open_collective': + $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']); + break; + case 'liberapay': + $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']); + break; + case 'ko_fi': + $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']); + break; + case 'issuehunt': + $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url']; + break; + case 'community_bridge': + $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']); + break; + } + } + + return $this->fundingInfo = $result; } /** From 0b9c658bef426a56dc3971e614028ff5078bcd95 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 28 Feb 2020 10:21:24 +0100 Subject: [PATCH 4/5] Add plugin-api-version used to generate a lock file in itself --- src/Composer/Package/Locker.php | 2 ++ tests/Composer/Test/InstallerTest.php | 1 + tests/Composer/Test/Package/LockerTest.php | 2 ++ 3 files changed, 5 insertions(+) diff --git a/src/Composer/Package/Locker.php b/src/Composer/Package/Locker.php index 57ec74233..8a500d837 100644 --- a/src/Composer/Package/Locker.php +++ b/src/Composer/Package/Locker.php @@ -19,6 +19,7 @@ use Composer\Util\ProcessExecutor; use Composer\Repository\ArrayRepository; use Composer\Package\Dumper\ArrayDumper; use Composer\Package\Loader\ArrayLoader; +use Composer\Plugin\PluginInterface; use Composer\Util\Git as GitUtil; use Composer\IO\IOInterface; use Seld\JsonLint\ParsingException; @@ -322,6 +323,7 @@ class Locker if ($platformOverrides) { $lock['platform-overrides'] = $platformOverrides; } + $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION; if (empty($lock['packages']) && empty($lock['packages-dev']) && empty($lock['platform']) && empty($lock['platform-dev'])) { if ($this->lockFile->exists()) { diff --git a/tests/Composer/Test/InstallerTest.php b/tests/Composer/Test/InstallerTest.php index 6a3d164c5..067baf17a 100644 --- a/tests/Composer/Test/InstallerTest.php +++ b/tests/Composer/Test/InstallerTest.php @@ -262,6 +262,7 @@ class InstallerTest extends TestCase unset($actualLock['hash']); unset($actualLock['content-hash']); unset($actualLock['_readme']); + unset($actualLock['plugin-api-version']); $this->assertEquals($expectLock, $actualLock); } diff --git a/tests/Composer/Test/Package/LockerTest.php b/tests/Composer/Test/Package/LockerTest.php index 3b887d06d..04e8e6c84 100644 --- a/tests/Composer/Test/Package/LockerTest.php +++ b/tests/Composer/Test/Package/LockerTest.php @@ -13,6 +13,7 @@ namespace Composer\Test\Package; use Composer\Package\Locker; +use Composer\Plugin\PluginInterface; use Composer\IO\NullIO; use Composer\Test\TestCase; @@ -154,6 +155,7 @@ class LockerTest extends TestCase 'platform-overrides' => array('foo/bar' => '1.0'), 'prefer-stable' => false, 'prefer-lowest' => false, + 'plugin-api-version' => PluginInterface::PLUGIN_API_VERSION, )); $locker->setLockData(array($package1, $package2), array(), array(), array(), array(), 'dev', array(), false, false, array('foo/bar' => '1.0')); From 8850e571de1704b521eae638df4ee1c8fd76bc8b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 28 Feb 2020 10:36:29 +0100 Subject: [PATCH 5/5] Remove file in favor of https://github.com/composer/.github/blob/master/FUNDING.yml --- .github/FUNDING.yml | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index d071feff1..000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,3 +0,0 @@ -# These are supported funding model platforms - -custom: https://packagist.com