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

cli: deploy: Add `--force` to redeploy everything

parent e44a3314
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,9 @@ class Deployment extends Unpacker {
'action'=>'store_true',
'help'=>'Use `git ls-files -s` as files source. Eliminates
possibility of deploying untracked files');
$this->options['force'] = array('-f', '--force',
'action'=>'store_true',
'help'=>'Deploy all files, even if they have not changed');
# super(*args);
call_user_func_array(array('parent', '__construct'), func_get_args());
}
......@@ -188,12 +191,13 @@ class Deployment extends Unpacker {
$dryrun = $this->getOption('dry-run', false);
$verbose = $this->getOption('verbose') || $dryrun;
$force = $this->getOption('force');
while ($line = stream_get_line($pipes[1], 255, "\x00")) {
list($mode, $hash, , $path) = preg_split('/\s+/', $line);
$src = $source.$local.$path;
if ($this->exclude($exclude, $src))
continue;
if (!$this->isChanged($src, $hash))
if (!$force && false === ($flag = $this->isChanged($src, $hash)))
continue;
$dst = $destination.$path;
if ($verbose)
......@@ -256,7 +260,8 @@ class Deployment extends Unpacker {
"*/.htaccess"));
}
$this->writeManifest($this->destination);
if (!$options['dry-run'])
$this->writeManifest($this->destination);
}
}
......
......@@ -156,6 +156,7 @@ class Unpacker extends Module {
function unpackage($folder, $destination, $recurse=0, $exclude=false) {
$dryrun = $this->getOption('dry-run', false);
$verbose = $this->getOption('verbose') || $dryrun;
$force = $this->getOption('force', false);
if (substr($destination, -1) !== '/')
$destination .= '/';
foreach (glob($folder, GLOB_BRACE|GLOB_NOSORT) as $file) {
......@@ -164,7 +165,8 @@ class Unpacker extends Module {
if (is_file($file)) {
$target = $destination . basename($file);
$hash = $this->hashFile($file);
if (is_file($target) && !$this->isChanged($file, $hash))
if (!$force && is_file($target)
&& false === ($flag = $this->isChanged($file, $hash)))
continue;
if ($verbose)
$this->stdout->write($target."\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment