diff --git a/rsync-antora-reference/src/rsync_docs.sh b/rsync-antora-reference/src/rsync_docs.sh index a2f6f62..8de9aa6 100755 --- a/rsync-antora-reference/src/rsync_docs.sh +++ b/rsync-antora-reference/src/rsync_docs.sh @@ -81,6 +81,9 @@ __rsync_docs() { if [ "$dry_run" != "false" ]; then rsync_opts="$rsync_opts --dry-run " fi + if [ -f "$local_path/.htaccess" ]; then + rsync_opts="$rsync_opts --include /.htaccess " + fi if [ -d "$local_path/.cache" ]; then rsync_opts="$rsync_opts$(find $local_path/.cache -printf ' --include /.cache/%P')" fi diff --git a/rsync-antora-reference/test/resources/test-rsync_docs.bats/htaccess/.htaccess b/rsync-antora-reference/test/resources/test-rsync_docs.bats/htaccess/.htaccess new file mode 100644 index 0000000..e69de29 diff --git a/rsync-antora-reference/test/test-rsync_docs.bats b/rsync-antora-reference/test/test-rsync_docs.bats index 2e5f9df..9495abe 100644 --- a/rsync-antora-reference/test/test-rsync_docs.bats +++ b/rsync-antora-reference/test/test-rsync_docs.bats @@ -63,4 +63,28 @@ usage: rsync_docs.sh [OPTION]... assert [ "$status" -eq 1 ] assert [ "${lines[0]}" = "Error: Missing option '--ssh-private-key-path'" ] assert [ "${lines[1]}" = 'usage: rsync_docs.sh [OPTION]...' ] +} + +@test "when exists .htaccess included before any excludes" { + local dir="${BATS_RESOURCE_TEMP_DIR}/htaccess" + stub rsync "$(capture_program_args "rsync")" + + run rsync_docs.sh --ssh-host HOST --build-ref-name main --ssh-host-path HOST_PATH --ssh-private-key-path PRIVATE_KEY_PATH --local-path "$dir" + + local rsync_args=$(get_program_args "rsync") + assert_success + assert_regex "$rsync_args" "^-c -avz --delete --include /.htaccess " + unstub rsync +} + +@test "when does not exists .htaccess not included" { + local dir="${BATS_RESOURCE_TEMP_DIR}/no-htaccess" + stub rsync "$(capture_program_args "rsync")" + + run rsync_docs.sh --ssh-host HOST --build-ref-name main --ssh-host-path HOST_PATH --ssh-private-key-path PRIVATE_KEY_PATH --local-path "$dir" + + local rsync_args=$(get_program_args "rsync") + assert_success + refute_regex "$rsync_args" " --include /.htaccess " + unstub rsync } \ No newline at end of file