Skip to content

feat(file-hash): auto-hash files found in CLI command arguments#108

Merged
alubbock merged 3 commits intomainfrom
feat/hash-cli-arg-files
Mar 19, 2026
Merged

feat(file-hash): auto-hash files found in CLI command arguments#108
alubbock merged 3 commits intomainfrom
feat/hash-cli-arg-files

Conversation

@alubbock
Copy link
Copy Markdown
Owner

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.

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.
@alubbock alubbock merged commit b778b17 into main Mar 19, 2026
20 checks passed
@alubbock alubbock deleted the feat/hash-cli-arg-files branch March 19, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant