-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
ci: add check to ensure composer-bin is not accidentally committed #52080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,11 @@ class InstalledVersions | |
| */ | ||
| private static $installed; | ||
|
|
||
| /** | ||
| * @var bool | ||
| */ | ||
| private static $installedIsLocalDir; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change is coming in from the latest composer 2.8 update (composer/composer#12269). |
||
|
|
||
| /** | ||
| * @var bool|null | ||
| */ | ||
|
|
@@ -309,6 +314,12 @@ public static function reload($data) | |
| { | ||
| self::$installed = $data; | ||
| self::$installedByVendor = array(); | ||
|
|
||
| // when using reload, we disable the duplicate protection to ensure that self::$installed data is | ||
| // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, | ||
| // so we have to assume it does not, and that may result in duplicate data being returned when listing | ||
| // all installed packages for example | ||
| self::$installedIsLocalDir = false; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -322,19 +333,27 @@ private static function getInstalled() | |
| } | ||
|
|
||
| $installed = array(); | ||
| $copiedLocalDir = false; | ||
|
|
||
| if (self::$canGetVendors) { | ||
| $selfDir = strtr(__DIR__, '\\', '/'); | ||
| foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { | ||
| $vendorDir = strtr($vendorDir, '\\', '/'); | ||
| if (isset(self::$installedByVendor[$vendorDir])) { | ||
| $installed[] = self::$installedByVendor[$vendorDir]; | ||
| } elseif (is_file($vendorDir.'/composer/installed.php')) { | ||
| /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */ | ||
| $required = require $vendorDir.'/composer/installed.php'; | ||
| $installed[] = self::$installedByVendor[$vendorDir] = $required; | ||
| if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { | ||
| self::$installed = $installed[count($installed) - 1]; | ||
| self::$installedByVendor[$vendorDir] = $required; | ||
| $installed[] = $required; | ||
| if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { | ||
| self::$installed = $required; | ||
| self::$installedIsLocalDir = true; | ||
| } | ||
| } | ||
| if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { | ||
| $copiedLocalDir = true; | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -350,7 +369,7 @@ private static function getInstalled() | |
| } | ||
| } | ||
|
|
||
| if (self::$installed !== array()) { | ||
| if (self::$installed !== array() && !$copiedLocalDir) { | ||
| $installed[] = self::$installed; | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,68 +1,5 @@ | ||
| { | ||
| "packages": [ | ||
| { | ||
| "name": "bamarni/composer-bin-plugin", | ||
| "version": "1.8.2", | ||
| "version_normalized": "1.8.2.0", | ||
| "source": { | ||
| "type": "git", | ||
| "url": "https://github.com/bamarni/composer-bin-plugin.git", | ||
| "reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880" | ||
| }, | ||
| "dist": { | ||
| "type": "zip", | ||
| "url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880", | ||
| "reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880", | ||
| "shasum": "" | ||
| }, | ||
| "require": { | ||
| "composer-plugin-api": "^2.0", | ||
| "php": "^7.2.5 || ^8.0" | ||
| }, | ||
| "require-dev": { | ||
| "composer/composer": "^2.0", | ||
| "ext-json": "*", | ||
| "phpstan/extension-installer": "^1.1", | ||
| "phpstan/phpstan": "^1.8", | ||
| "phpstan/phpstan-phpunit": "^1.1", | ||
| "phpunit/phpunit": "^8.5 || ^9.5", | ||
| "symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", | ||
| "symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0", | ||
| "symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0" | ||
| }, | ||
| "time": "2022-10-31T08:38:03+00:00", | ||
| "type": "composer-plugin", | ||
| "extra": { | ||
| "class": "Bamarni\\Composer\\Bin\\BamarniBinPlugin" | ||
| }, | ||
| "installation-source": "dist", | ||
| "autoload": { | ||
| "psr-4": { | ||
| "Bamarni\\Composer\\Bin\\": "src" | ||
| } | ||
| }, | ||
| "notification-url": "https://packagist.org/downloads/", | ||
| "license": [ | ||
| "MIT" | ||
| ], | ||
| "description": "No conflicts for your bin dependencies", | ||
| "keywords": [ | ||
| "composer", | ||
| "conflict", | ||
| "dependency", | ||
| "executable", | ||
| "isolation", | ||
| "tool" | ||
| ], | ||
| "support": { | ||
| "issues": "https://github.com/bamarni/composer-bin-plugin/issues", | ||
| "source": "https://github.com/bamarni/composer-bin-plugin/tree/1.8.2" | ||
| }, | ||
| "install-path": "../bamarni/composer-bin-plugin" | ||
| } | ||
| ], | ||
| "dev": true, | ||
| "dev-package-names": [ | ||
| "bamarni/composer-bin-plugin" | ||
| ] | ||
| "packages": [], | ||
| "dev": false, | ||
| "dev-package-names": [] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running composer install will install the dev dependencies again and therefore needs to go. I'm not so sure anymore, but still think that our state in github should not contain the composer-bin-plugin.
The drone workflow did not run composer install (see #43514 and https://github.com/nextcloud/server/blob/master/autotest-checkers.sh).
Requested @susnux as reviewer for a third look if that makes sense.