Skip to content

Commit

Permalink
Config - always respect COMPOSER_DISCARD_CHANGES
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes authored and Seldaek committed Aug 30, 2022
1 parent a1bc424 commit 13421f7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Composer/Config.php
Expand Up @@ -376,7 +376,8 @@ public function get(string $key, int $flags = 0)
return $value;

case 'discard-changes':
if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
$env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES');
if ($env !== false) {
if (!in_array($env, ['stash', 'true', 'false', '1', '0'], true)) {
throw new \RuntimeException(
"Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
Expand Down Expand Up @@ -519,7 +520,7 @@ private function realpath(string $path): string
* This should be used to read COMPOSER_ environment variables
* that overload config values.
*
* @return string|bool
* @return string|false
*/
private function getComposerEnv(string $var)
{
Expand Down

0 comments on commit 13421f7

Please sign in to comment.