Skip to content

Commit

Permalink
rsync includes .htaccess for branch specific build
Browse files Browse the repository at this point in the history
Closes gh-18
  • Loading branch information
rwinch committed Jan 19, 2024
1 parent de63de2 commit 26e3ef2
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions rsync-antora-reference/src/rsync_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
24 changes: 24 additions & 0 deletions rsync-antora-reference/test/test-rsync_docs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 26e3ef2

Please sign in to comment.