HashBeaf
You don't like your git commit hash dc3fe60?
Or any of your others hashes?
With HashBeaf you can easily create hashes with words that you like in it, such as c0dec, abba 🎵, cafe ☕ or deadbeef 🐮.
The last one is probably too long to work, so let's try beaf as hash instead (now you understand the name - not a typo 😉).
The way this works is that it computes a commit time based on your previous commit to get the right hash, so do use it with care.
Example
So you've made some changes to your git repository and staged some files. Now, it is time to make a commit as normal:
$ git commit -m "Updated code"
[main b1c825b] Updated code
12 files changed, 215 insertions(+), 2 deletions(-)
(...)
But before you push, you think, meh, b1c825b, I can do better than that.
Now it is time to run HashBeaf:
$ hashbeaf c0de
[main c0de2c4] Updated code
Date: Mon Jun 26 20:43:07 2023 +0200
(...)
And voila, we have c0de2c4, our HashBeaf'ed commit hash!
Want to try it yourself?
Install it with:
pip install hashbeaf
Then navigate to your own git repository, make a commit, and then run either:
hashbeaf
to use a default list of nice 'words', or something like this for a custom 'word':
hashbeaf c0de
See hashbeaf --help for more information.
There is also a hb alias if you don't want to type 8 characters.
If you think it is too much work to run this after each commit, you can also install a git post-commit hook for your repository.
Modify post-commit to point to the right absolute path (and customize it further as needed), and simple copy it to your_repo/.git/hooks.
On the next commit hashbeaf should run automatically.
Need some inspiration? Check out the default words list for nice commit hashes, or see more on Wikipedia here and here.
Implementation details
The algorithm is inspired by beautify_git_hash, a slightly outdated tool that achieves the same thing.
HashBeaf is implemented in Python and requires version 3.7 or newer. It has been tested on Linux but might run on other operation systems.
HashBeaf works as follows. A commit hash in git is computed based on the commit details, which include the commit message, author time and committer time. If we modify any of those, we get a new commit hash. With HashBeaf we set the author time and committer time to some time in the near future, compute a new hash, and if the hash starts with any of the user supplied 'words', we amend the previous commit by running something like:
GIT_COMMITTER_DATE=$(some_commit_time) git commit --amend -C HEAD --date=$(some_author_time)
HashBeaf keeps on changing the two times until either the given maximum time is reached or the nice hash is found.
The algorithm tries to found times as close as possible to the actual commit/author times.
For longer words (i.e. 5 characters or more) it is likely that the default maximum time is not enough: setting --max_minutes_in_future is recommended.
However, be careful with increasing the time: it might confuse other users of your repository or can lead to incorrectly sorted commits in logs.
For developers
Instead of installing the package through pip, you can also run the script directly after checking out the repository as e.g.:
python3 -m src.hashbeaf.hashbeaf c0de
Feature wish list
Missing a feature? Soon there will be also:
- More documentation
- More error checking
Metadata
Release files for hashbeaf 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| hashbeaf-1.1.1.tar.gz | 9.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hashbeaf-1.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.5 kB
Release files / hashbeaf-1.1.1.tar.gz
| Download URL | hashbeaf-1.1.1.tar.gz |
|---|---|
| Size | 9.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
95ad631991b53c494ec22164022fbbe7bbb607a0c55c33dc67a221629b139fc8
|
|
BLAKE2b-256 checksum How to use checksums |
40ec6b7494bc6c43fd7d97c4bbc45be6dffb43f4d2d79c698d0465b752167714
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Release files / hashbeaf-1.1.1-py3-none-any.whl
| Download URL | hashbeaf-1.1.1-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c720c616a095a60ad9e30e9671ac38751db4e13071fe9f44c182515e5152dcef
|
|
BLAKE2b-256 checksum How to use checksums |
a51ca2f0bb9ef11fb018ca304d16078aba1b7e269e8af4939ad00380047e87b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.5
|
Security for hashbeaf 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.