Skip to content
Snippets Groups Projects
Commit 35db37d4 authored by Jared Hancock's avatar Jared Hancock
Browse files

cli: deploy: Don't remove the .MANIFEST or ost-config.php files

parent 93402825
No related branches found
No related tags found
No related merge requests found
...@@ -48,13 +48,14 @@ class Deployment extends Unpacker { ...@@ -48,13 +48,14 @@ class Deployment extends Unpacker {
* Removes files from the deployment location that no longer exist in * Removes files from the deployment location that no longer exist in
* the local repository * the local repository
*/ */
function clean($local, $destination, $recurse=0, $exclude=false) { function clean($local, $destination, $root, $recurse=0, $exclude=false) {
$dryrun = $this->getOption('dry-run', false); $dryrun = $this->getOption('dry-run', false);
$verbose = $dryrun || $this->getOption('verbose'); $verbose = $dryrun || $this->getOption('verbose');
$destination = rtrim($destination, '/') . '/'; $destination = rtrim($destination, '/') . '/';
$contents = glob($destination.'{,.}*', GLOB_BRACE|GLOB_NOSORT); $contents = glob($destination.'{,.}*', GLOB_BRACE|GLOB_NOSORT);
foreach ($contents as $i=>$file) { foreach ($contents as $i=>$file) {
if ($this->exclude($exclude, $file)) $relative = str_replace($root, "", $file);
if ($this->exclude($exclude, $relative))
continue; continue;
if (is_file($file)) { if (is_file($file)) {
$ltarget = $local . '/' . basename($file); $ltarget = $local . '/' . basename($file);
...@@ -77,12 +78,13 @@ class Deployment extends Unpacker { ...@@ -77,12 +78,13 @@ class Deployment extends Unpacker {
foreach ($folders as $dir) { foreach ($folders as $dir) {
if (in_array(basename($dir), array('.','..'))) if (in_array(basename($dir), array('.','..')))
continue; continue;
elseif ($this->exclude($exclude, $dir)) $relative = str_replace($root, "", $dir);
if ($this->exclude($exclude, "$relative/"))
continue; continue;
$this->clean( $this->clean(
$local.'/'.basename($dir), $local.'/'.basename($dir),
$destination.basename($dir), $destination.basename($dir),
$recurse - 1, $exclude); $root, $recurse - 1, $exclude);
} }
} }
if (!$contents || !glob($destination.'{,.}*', GLOB_BRACE|GLOB_NOSORT)) { if (!$contents || !glob($destination.'{,.}*', GLOB_BRACE|GLOB_NOSORT)) {
...@@ -259,7 +261,7 @@ class Deployment extends Unpacker { ...@@ -259,7 +261,7 @@ class Deployment extends Unpacker {
$exclusions); $exclusions);
# Unpack the include folder # Unpack the include folder
$this->unpackage("$root/include/{,.}*", $include, -1, $this->unpackage("$root/include/{,.}*", $include, -1,
array("*/include/ost-config.php")); array("*/include/ost-config.php", "*.sw[a-z]"));
if (!$options['dry-run']) { if (!$options['dry-run']) {
if ($include != "{$this->destination}/include/") if ($include != "{$this->destination}/include/")
$this->change_include_dir($include); $this->change_include_dir($include);
...@@ -267,11 +269,12 @@ class Deployment extends Unpacker { ...@@ -267,11 +269,12 @@ class Deployment extends Unpacker {
if ($options['clean']) { if ($options['clean']) {
// Clean everything but include folder first // Clean everything but include folder first
$this->clean($root, $this->destination, -1, $local_include = str_replace($this->destination, "", $include);
array($include, "setup/")); $this->clean($root, $this->destination, $this->destination, -1,
$this->clean("$root/include", $include, -1, array($local_include, "setup/"));
$this->clean("$root/include", $include, $include, -1,
array("ost-config.php","settings.php","plugins/", array("ost-config.php","settings.php","plugins/",
"*/.htaccess")); "*/.htaccess", ".MANIFEST"));
} }
if (!$options['dry-run']) if (!$options['dry-run'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment