Code reorgs and make bool values real booleans, refs #1637
parent
8eb71f5478
commit
f06c0cb580
|
@ -623,8 +623,10 @@ The following options are supported:
|
||||||
define a notification URL, so that they get notified whenever a package from
|
define a notification URL, so that they get notified whenever a package from
|
||||||
that repository is installed. This option allows you to disable that behaviour.
|
that repository is installed. This option allows you to disable that behaviour.
|
||||||
* **discard-changes:** Defaults to `false` and can be any of `true`, `false` or
|
* **discard-changes:** Defaults to `false` and can be any of `true`, `false` or
|
||||||
`stash`. This option allows you to set the default style of handling dirty
|
`"stash"`. This option allows you to set the default style of handling dirty
|
||||||
updates, specially useful for non-interactive mode.
|
updates when in non-interactive mode. `true` will always discard changes in
|
||||||
|
vendors, while `"stash"` will try to stash and reapply. Use this for CI
|
||||||
|
servers or deploy scripts if you tend to have modified vendors.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
|
|
@ -169,8 +169,8 @@
|
||||||
"description": "The cache max size for the files cache, defaults to \"300MiB\"."
|
"description": "The cache max size for the files cache, defaults to \"300MiB\"."
|
||||||
},
|
},
|
||||||
"discard-changes": {
|
"discard-changes": {
|
||||||
"type": ["string"],
|
"type": ["string", "boolean"],
|
||||||
"description": "The default style of handling dirty updates, defaults to \"false\" and can be any of \"true\", \"false\" or \"stash\"."
|
"description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -252,11 +252,11 @@ EOT
|
||||||
$uniqueConfigValues = array(
|
$uniqueConfigValues = array(
|
||||||
'process-timeout' => array('is_numeric', 'intval'),
|
'process-timeout' => array('is_numeric', 'intval'),
|
||||||
'use-include-path' => array(
|
'use-include-path' => array(
|
||||||
function ($val) { return true; },
|
function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); },
|
||||||
function ($val) { return $val !== 'false' && (bool) $val; }
|
function ($val) { return $val !== 'false' && (bool) $val; }
|
||||||
),
|
),
|
||||||
'notify-on-install' => array(
|
'notify-on-install' => array(
|
||||||
function ($val) { return true; },
|
function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); },
|
||||||
function ($val) { return $val !== 'false' && (bool) $val; }
|
function ($val) { return $val !== 'false' && (bool) $val; }
|
||||||
),
|
),
|
||||||
'vendor-dir' => array('is_string', function ($val) { return $val; }),
|
'vendor-dir' => array('is_string', function ($val) { return $val; }),
|
||||||
|
@ -272,8 +272,13 @@ EOT
|
||||||
function ($val) { return $val; }
|
function ($val) { return $val; }
|
||||||
),
|
),
|
||||||
'discard-changes' => array(
|
'discard-changes' => array(
|
||||||
function ($val) { return in_array($val, array('true', 'false', 'stash')); },
|
function ($val) { return in_array($val, array('stash', 'true', 'false', '1', '0'), true); },
|
||||||
function ($val) { return $val; }
|
function ($val) {
|
||||||
|
if ('stash' === $val) {
|
||||||
|
return 'stash';
|
||||||
|
}
|
||||||
|
return $val !== 'false' && (bool) $val;
|
||||||
|
}
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
$multiConfigValues = array(
|
$multiConfigValues = array(
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Config
|
||||||
'cache-ttl' => 15552000, // 6 months
|
'cache-ttl' => 15552000, // 6 months
|
||||||
'cache-files-ttl' => null, // fallback to cache-ttl
|
'cache-files-ttl' => null, // fallback to cache-ttl
|
||||||
'cache-files-maxsize' => '300MiB',
|
'cache-files-maxsize' => '300MiB',
|
||||||
'discard-changes' => 'false',
|
'discard-changes' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $defaultRepositories = array(
|
public static $defaultRepositories = array(
|
||||||
|
@ -145,7 +145,7 @@ class Config
|
||||||
case 'cache-files-maxsize':
|
case 'cache-files-maxsize':
|
||||||
if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
|
if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
"Could not parse the value of 'cache-files-maxsize' from your config: {$this->config[$key]}"
|
"Could not parse the value of 'cache-files-maxsize': {$this->config[$key]}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$size = $matches[1];
|
$size = $matches[1];
|
||||||
|
@ -176,9 +176,9 @@ class Config
|
||||||
return rtrim($this->process($this->config[$key]), '/\\');
|
return rtrim($this->process($this->config[$key]), '/\\');
|
||||||
|
|
||||||
case 'discard-changes':
|
case 'discard-changes':
|
||||||
if (!in_array($this->config[$key], array('true', 'false', 'stash'))) {
|
if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
|
||||||
throw new \RuntimeException(
|
throw new \RuntimeException(
|
||||||
"Invalid value of 'discard-changes' from your config: {$this->config[$key]}"
|
"Invalid value for 'discard-changes': {$this->config[$key]}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,23 +94,20 @@ class GitDownloader extends VcsDownloader
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$discardChanges = $this->config->get('discard-changes');
|
|
||||||
if (!$this->io->isInteractive()) {
|
if (!$this->io->isInteractive()) {
|
||||||
switch ($discardChanges) {
|
$discardChanges = $this->config->get('discard-changes');
|
||||||
case 'true':
|
if (true === $discardChanges) {
|
||||||
return $this->discardChanges($path);
|
return $this->discardChanges($path);
|
||||||
|
|
||||||
case 'stash':
|
|
||||||
if (!$update) {
|
|
||||||
return parent::cleanChanges($path, $update);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->stashChanges($path);
|
|
||||||
|
|
||||||
case 'false':
|
|
||||||
default:
|
|
||||||
return parent::cleanChanges($path, $update);
|
|
||||||
}
|
}
|
||||||
|
if ('stash' === $discardChanges) {
|
||||||
|
if (!$update) {
|
||||||
|
return parent::cleanChanges($path, $update);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->stashChanges($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::cleanChanges($path, $update);
|
||||||
}
|
}
|
||||||
|
|
||||||
$changes = array_map(function ($elem) {
|
$changes = array_map(function ($elem) {
|
||||||
|
|
|
@ -92,17 +92,12 @@ class SvnDownloader extends VcsDownloader
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$discardChanges = $this->config->get('discard-changes');
|
|
||||||
if (!$this->io->isInteractive()) {
|
if (!$this->io->isInteractive()) {
|
||||||
switch ($discardChanges) {
|
if (true === $this->config->get('discard-changes')) {
|
||||||
case 'true':
|
return $this->discardChanges($path);
|
||||||
return $this->discardChanges($path);
|
|
||||||
|
|
||||||
case 'false':
|
|
||||||
case 'stash':
|
|
||||||
default:
|
|
||||||
return parent::cleanChanges($path, $update);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return parent::cleanChanges($path, $update);
|
||||||
}
|
}
|
||||||
|
|
||||||
$changes = array_map(function ($elem) {
|
$changes = array_map(function ($elem) {
|
||||||
|
|
Loading…
Reference in New Issue