feat(file-hash): auto-hash files found in CLI command arguments#108
Merged
feat(file-hash): auto-hash files found in CLI command arguments#108
Conversation
Extend _resolve_cmd_path so that, in addition to resolving the command executable (cmd[0]) via shutil.which, it scans cmd[1:] for tokens that correspond to existing files on disk. Any matching argument path is appended to the hash list, so input/output files passed on the command line are captured transparently without requiring --hash-file. The change is backward-compatible: users who supply --hash-file explicitly still override the default entirely; the Python API (which never calls _resolve_cmd_path) is unaffected.
Six new tests covering the updated _resolve_cmd_path behaviour: - argument files are included in the default hash list - non-existent paths in arguments are silently skipped - flag-like tokens (--flag, -n, bare numbers) are not matched - directory paths in arguments are not hashed - explicit --hash-file overrides the default entirely - duplicate file arguments do not cause errors
Update the file-hash section of docs/cli.md and docs/user-guide/mixins.md to explain that the CLI default now hashes the command executable plus any arguments that resolve to existing files. Add a concrete example command and note that --hash-file overrides the default entirely. Add an [Unreleased] entry to CHANGELOG.md.
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.
Extend _resolve_cmd_path so that, in addition to resolving the command
executable (cmd[0]) via shutil.which, it scans cmd[1:] for tokens that
correspond to existing files on disk. Any matching argument path is
appended to the hash list, so input files passed on the command
line are captured transparently without requiring --hash-file.
The hash algorithm name is now captured in
mb.file_hash_algorithm.The change is backward-compatible: users who supply --hash-file
explicitly still override the default entirely; the Python API (which
never calls _resolve_cmd_path) is unaffected.