Fix your damn commit message grammar!
Project description
Fix your damn commit message grammar!
TL;DR: Commit in imperative mood
What does this do?
This is a commit-msg git hook (i.e. it runs just after you made a commit, checking your commit message) that fixes your commit if it doesn’t follow the proper grammatical rules.
This project doesn’t care about the semantics of your commits, you should already know how to properly convey the idea of your changes in the message (separate commits for logically separate changes, meaningful messages, yada yada). grammaticommit only cares about the grammar rules of the message itself.
Also, it only cares about the subject of the commit message, not the body, where the rules are a little bit more relaxed.
How do I use it?
First we need to install the package
pip install grammaticommit
Then, we have the commands to install and uninstall the hook
Install the hook for the current repo (this should be used within the repo root): grammaticommit
Install the hook globally for all of your git repos: grammaticommit --global
Uninstall the hook for the current repo (this should be used within the repo root): grammaticommit --uninstall
Uninstall the hook for all of your git repos: grammaticommit --global --uninstall
Remember that if for whatever reason (a false negative in your commit message, for example) you want to skip the check for a single commit, you can always run git commit -m "My message" --no-verify
If you encounter any false negative (a commit message that follows the guidelines, yet it’s being flagged as incorrect, or even being wrongly fixed), please raise up an issue so that I can fix it.
Python Versions
This package correctly works for Python 3.6, but needs a quick fix for Python 3.7 and onwards. Currently, the library that is used to check for the imperative mood is not compatible on their main release with Py>=3.7. To fix this, we must use a dev dependency. So, after doing the pip install grammaticommit one must run pip install git+git://github.com/clips/pattern.git@17f215438166729114762c3d9b3179dacd31490d
Commit grammar
Over the years, everyone and their mother has had an opinion on how to write a proper commit message. There is, however, a canonical way to write commit messages… the Linus way!
Besides using Linus’ ideas, I also incorporated (as long as they don’t contradict Linus) two more sources, Tim Pope, and Chris Beams, whom had written two blog posts that are constantly being shared and used as the bible in terms of how to write a good commit message.
So, the full list of sources for this is, in order of priority:
Guidelines for submitting pathes into the git repository (you can’t get any more official than this)
Tim Pope’s famous 2008 blog post, “A Note About Git Commit Messages”
Chris Beans’ a little bit more recent blog post, 2014’s “How to Write a Git Commit Message”
From all of this sources, the final list of rules that this project follows is…
Imperative mood, always
50 characters
No trailing period (you are using one precious character!)
Optionally, declare the area of the project in which the commit makes changes, prefixing the message with the area and a colon
Note that not everything from the 3 sources was taken into account, only an intersection of them. For example, while Chris and Tim suggest to capitalize the commit, Linus says to commit all in lowercase, so grammaticommit takes no stance on the matter (specially in this particular case because people tend to capitalize everything, in other cases I tend to take Linus word over the rest).
If you have any other grammar rule that a commit message should follow, backed with good sources, make an issue, and I’ll add it.
PS: This doesn’t apply to “Initial Commit” messages.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file grammaticommit-0.5.tar.gz
.
File metadata
- Download URL: grammaticommit-0.5.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91bf08c1f55d0a994f741c501e9d2765c839c3016c5aa2d6316356cc3fde5ae5 |
|
MD5 | f73d56f41dad37a4d2d1193ae6f9bb8c |
|
BLAKE2b-256 | aa0633c85f5fa34d8111d55c065c7023bcfa636851c46d9c668185063a853493 |
File details
Details for the file grammaticommit-0.5-py3-none-any.whl
.
File metadata
- Download URL: grammaticommit-0.5-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffa0bf1e1bc013baec9c08679c9d51f098754df2471e8024be830f564794e1ee |
|
MD5 | ab5acc638b8af4fca2525dedcad6860c |
|
BLAKE2b-256 | c49ce5695a2bab8ab046a4c506fa3df9ff1b59f25c6a28d86f05f267051348cb |