Closes #186. Normally I would split these into separate PRs, but in the interest of putting #186 to bed and moving on, I'm eliding them here.
@go.canonicalize_path now accepts --pwd and --parent <dir> options for convenience, rather than forcing the caller to use @go.add_parent_dir_if_relative_path directly.
@go.mirror_directory now mirrors the entire source directory by default.
@go.create_gzipped_tarball throws in tons of sanity checks and provides maximum portability, when a handful of direct commands just won't do. (The same could be said for @go.mirror_directory.)
create_fake_tarball_if_not_using_real_url now uses @go.mirror_directory, but not @go.create_gzipped_tarball, since the latter follows the convention that the extracted directory matches the basename of the tarball. With GitHub releases, the name of the extracted directory does not match the basename of the tarball, e.g. v1.6.0.tar.gz extracts to go-script-bash-v1.6.0. So in this case, it was easier to use @go.mirror_directory, then use tar directly, despite the fact that create_fake_tarball_if_not_using_real_url inspired @go.create_gzipped_tarball, which then inspired @go.mirror_directory.
(If @go.create_gzipped_tarball doesn't prove useful in the long run, I can remove it in v2.0.0.)
Finally, after digging deeper into process substitution vs. pipes during the implementation of @go.mirror_directory from lib/fileutil, I realized a few things:
The same number of processes are spawned.
There's little benefit to a process substitution for straightforward pipes when the output isn't consumed by the shell process.
It's not straightforward to get the status from a process substitution, and neither '$!' nor wait help.
The 'PIPESTATUS' variable is available to check the status of each process in the pipe, without the need for set -o pipefail.
Hence, go-template now uses a {curl,fetch,cat,wget} | tar pipe with a [[ ${PIPESTATUS[0]} -ne '0' ]] check. There's a new test case for tar failure, and the 'fail to download ...' test cases required a little tweaking to ensure they properly cover the cases where ${download_cmd[@]} fails.
Coverage increased (+0.07%) to 95.145% when pulling 41daa0cc87a318728908eb8f5fc1644d1af76688 on tarball-#186 into 2f731d6e38743a97f35f4034d5435ed78ca0f7dc on master.
Coverage increased (+0.07%) to 95.145% when pulling d60a27230ed6fa130f3c4c483d03fe71fac4ed58 on tarball-#186 into 2f731d6e38743a97f35f4034d5435ed78ca0f7dc on master.
Coverage increased (+0.07%) to 95.145% when pulling e885b4a752d704e5d525418de7e4e4acd627c071 on tarball-#186 into 2f731d6e38743a97f35f4034d5435ed78ca0f7dc on master.
Closes #186. Normally I would split these into separate PRs, but in the interest of putting #186 to bed and moving on, I'm eliding them here.
@go.canonicalize_path
now accepts--pwd
and--parent <dir>
options for convenience, rather than forcing the caller to use@go.add_parent_dir_if_relative_path
directly.@go.mirror_directory
now mirrors the entire source directory by default.@go.create_gzipped_tarball
throws in tons of sanity checks and provides maximum portability, when a handful of direct commands just won't do. (The same could be said for@go.mirror_directory
.)create_fake_tarball_if_not_using_real_url
now uses@go.mirror_directory
, but not@go.create_gzipped_tarball
, since the latter follows the convention that the extracted directory matches the basename of the tarball. With GitHub releases, the name of the extracted directory does not match the basename of the tarball, e.g.v1.6.0.tar.gz
extracts togo-script-bash-v1.6.0
. So in this case, it was easier to use@go.mirror_directory
, then usetar
directly, despite the fact thatcreate_fake_tarball_if_not_using_real_url
inspired@go.create_gzipped_tarball
, which then inspired@go.mirror_directory
.(If
@go.create_gzipped_tarball
doesn't prove useful in the long run, I can remove it in v2.0.0.)Finally, after digging deeper into process substitution vs. pipes during the implementation of
@go.mirror_directory
fromlib/fileutil
, I realized a few things:wait
help.set -o pipefail
.Hence,
go-template
now uses a{curl,fetch,cat,wget} | tar
pipe with a[[ ${PIPESTATUS[0]} -ne '0' ]]
check. There's a new test case fortar
failure, and the 'fail to download ...' test cases required a little tweaking to ensure they properly cover the cases where${download_cmd[@]}
fails.(Yeah, really shoulda been separate PRs.)