Skip to content

Commit

Permalink
rsync-antora-reference.sh returns rsync status code
Browse files Browse the repository at this point in the history
Closes gh-28
  • Loading branch information
rwinch committed Jun 19, 2024
1 parent 5a57bcc commit 852920b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rsync-antora-reference/src/rsync_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ __rsync_docs() {
fi
# Disable filename expansion (globbing)
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
set -f
rsync $rsync_opts -e "ssh -i $ssh_private_key_path" $local_path/ "$ssh_host:$ssh_host_path"
set +f
(
set -f
rsync $rsync_opts -e "ssh -i $ssh_private_key_path" $local_path/ "$ssh_host:$ssh_host_path"
)
}


Expand Down
10 changes: 10 additions & 0 deletions rsync-antora-reference/test/test-rsync_docs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,14 @@ usage: rsync_docs.sh [OPTION]...
assert_success
refute_regex "$rsync_args" " --include /.htaccess "
unstub rsync
}

@test "when rsync fails script returns non-zero" {
local dir="${BATS_RESOURCE_TEMP_DIR}/no-htaccess"
stub rsync "exit 1"

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"

assert_failure
unstub rsync
}

0 comments on commit 852920b

Please sign in to comment.