zola
zola copied to clipboard
add get_hash function
Hello,
I saw the Discourse topic which got no answers yet, so I decided to give it a try (as I need this feature myself).
It’s basically a rough copy of get_file_hash
but it takes a string literal in parameter instead of a file.
It was easier to adapt this function (and tests/documentation) than writing a filter instead. I hope this implementation still satisfies your expectations.
Sanity check:
- [x] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
Code changes
(Delete or ignore this section for documentation changes)
- [x] Are you doing the PR on the
next
branch?
If the change is a new feature or adding to/changing an existing one:
- [x] Have you created/updated the relevant documentation page(s)?
Can you rebase the PR?
Done!
I reworked the PR to merge get_hash and get_file_hash into a common function (process_hashes
) to minimize the amount of duplicated lines of code.
Though I couldn’t completely get rid of compute_file_hash
because another function is using it and I have no clue how to get around those and_then()
… Sorry for my lack of experience.
Any chance you can rebase + fix conflict? I'll merge it after, it looks good.
Should be fine now :)
As requested, I removed the get_file_hash
function and added path
argument to get_hash
. I’ve updated the documentation and tests to reflect this change.
(I also managed to get rid of compute_file_hash
somehow)