Skip to content
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

Added option to ignore files/folders on remote side #160

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ ignore = "
!temp/.htaccess
"

; if no, ignore section will be taken into account on remote side (default is yes)
ignoreRemote = yes

; explicit list of files and directories to include (by default includes all files and directories)
include = "
/app
Expand Down
2 changes: 2 additions & 0 deletions src/Deployment/CliRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CliRunner
'passivemode' => true,
'include' => '',
'ignore' => '',
'ignoreremote' => true,
'allowdelete' => true,
'purge' => '',
'before' => '',
Expand Down Expand Up @@ -169,6 +170,7 @@ private function createDeployer(array $config): Deployer
? $deployment->deploymentFile
: $config['deploymentfile'];
$deployment->allowDelete = (bool) $config['allowdelete'];
$deployment->ignoreRemote = (bool) $config['ignoreremote'];
$deployment->toPurge = self::toArray($config['purge'], true);
$deployment->runBefore = self::toArray($config['before'], true);
$deployment->runAfterUpload = self::toArray($config['afterupload'], true);
Expand Down
10 changes: 9 additions & 1 deletion src/Deployment/Deployer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class Deployer
/** @var string[] */
public array $ignoreMasks = [];

public bool $ignoreRemote = true;

public bool $testMode = false;

public bool $allowDelete = false;
Expand Down Expand Up @@ -227,7 +229,13 @@ private function loadDeploymentFile(): ?array
$res = [];
foreach (explode("\n", $content) as $item) {
if (count($item = explode('=', $item, 2)) === 2) {
$res[$item[1]] = $item[0] === '1' ? true : $item[0];
if ($this->ignoreRemote === true) {
$res[$item[1]] = $item[0] === '1' ? true : $item[0];
}else {
if (Helpers::matchMask($item[1], $this->ignoreMasks, is_dir("$this->remoteDir/$item[1]")) === false) {
$res[$item[1]] = $item[0] === '1' ? true : $item[0];
}
}
}
}
return $res;
Expand Down