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

Use --include before --exclude in rsync commands #1304

Merged
merged 3 commits into from
Aug 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion src/Command/Mount/MountDownloadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function configure()
->addOption('source-path', null, InputOption::VALUE_NONE, "Use the mount's source path (rather than the mount path) as a subdirectory of the target, when --all is used")
->addOption('delete', null, InputOption::VALUE_NONE, 'Whether to delete extraneous files in the target directory')
->addOption('exclude', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED, 'File(s) to exclude from the download (pattern)')
->addOption('include', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED, 'File(s) to include in the download (pattern)')
->addOption('include', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED, 'File(s) not to exclude (pattern)')
->addOption('refresh', null, InputOption::VALUE_NONE, 'Whether to refresh the cache');
$this->addProjectOption();
$this->addEnvironmentOption();
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Mount/MountUploadCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected function configure()
->addOption('mount', 'm', InputOption::VALUE_REQUIRED, 'The mount (as an app-relative path)')
->addOption('delete', null, InputOption::VALUE_NONE, 'Whether to delete extraneous files in the mount')
->addOption('exclude', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED, 'File(s) to exclude from the upload (pattern)')
->addOption('include', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED, 'File(s) to include in the upload (pattern)')
->addOption('include', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_REQUIRED, 'File(s) not to exclude (pattern)')
->addOption('refresh', null, InputOption::VALUE_NONE, 'Whether to refresh the cache');
$this->addProjectOption();
$this->addEnvironmentOption();
Expand Down
12 changes: 11 additions & 1 deletion src/Service/Rsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,17 @@ private function doSync($from, $to, array $options = [])
if (!empty($options['delete'])) {
$params[] = '--delete';
}
foreach (['exclude', 'include'] as $option) {

// Add include and exclude rules.
//
// The --include option should be placed before --exclude. From the
// rsync manual:
// "The order of the rules is important because the first rule that
// matches is the one that takes effect. Thus, if an early rule
// excludes a file, no include rule that comes after it can have any
// effect. This means that you must place any include overrides
// somewhere prior to the exclude that it is intended to limit."
foreach (['include', 'exclude'] as $option) {
if (!empty($options[$option])) {
foreach ($options[$option] as $value) {
$params[] = '--' . $option . '=' . $value;
Expand Down
Loading