Repository navigation
fix: an unreadable template no longer runs a same-named program - #541
Open
connorburgess wants to merge 1 commit into
Open
connorburgess wants to merge 1 commit into
connorburgess wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A template file that is there but can't be read as one (no read permission, bytes that aren't UTF-8, a symlink whose target is gone, or a folder named like a template) shows up in
hc templatesas broken, buthc run <name> "task"took it for "no such template" and tried to start a program called<name>: it failed with a spawn error about the program name, or quietly started an installed program of the same name with the task text as its arguments.templates::loadnow reports the existinginvalid_templateerror, naming the file and the read error, when something is at the template's path but reading it fails. When there is nothing at that path to see (no file, no templates folder, a file where the folder should be, a templates folder that can't be searched, or a program name that isn't a valid file name), the name is still just a program and runs as before.hc templatesnow shows such an entry's read error after its path instead of a bare "unreadable", the same way it already shows parse errors.The new unit test
templates::tests::only_a_missing_template_file_is_no_templatecovers a missing file, a file with invalid UTF-8, a folder namedfolder.md, and a templates folder that isn't there; it fails on master 0b968a2 and passes on the branch. A dangling symlink takes the same path but is not in the test, which stays portable.Checks on the final head, rebased on master 0b968a2 (macOS):
cargo build --locked -p herdr-corefinishes.cargo test --locked -p herdr-core --lib templates::gives 3 passed; with master'sloadand the new test it gives 2 passed, 1 failed (panicked at crates/herdr-core/src/templates.rs:240:42).just lintpasses:cargo fmt --all -- --check,cargo deny check("advisories ok, bans ok, licenses ok, sources ok"),cargo clippy --locked --all-targets -- -D warnings, and the Windows clippy (run withAR_x86_64_pc_windows_msvcpointed at a Homebrew llvm-ar, since this Mac has nollvm-aron PATH).just docs-checkpasses (cli_docs: 2 passed).cargo test --locked --no-fail-fastruns to the end with 725 passed, 5 failed, 4 ignored. The five failures are outside templates and fail the same way on unmodified master 0b968a2 on this Mac: distribution'sa_machine_of_another_cpu_gets_the_released_build_for_itand machines'interactive_add_uses_the_same_ssh_target_for_login_and_install(both time out in the wait at tests/common/mod.rs:343), and home'smembership::join_supports_code_arg_ssh_target_and_tty_enter_prompt,transport::relay_off_unreachable_message_and_instant_inbound_shared_connectionandtransport::a_same_instance_can_replace_its_stream_and_then_its_connection.Checked on macOS only. Not checked: Linux, Windows.