User:Evilpie/commit-restrictions: Difference between revisions
Line 53: | Line 53: | ||
</pre> | </pre> | ||
You probably need to add good_commit_message to your Python path | You probably need to add good_commit_message to your Python path | ||
<pre> | <pre> | ||
export PYTHONPATH = ~/myhooks # assuming good_commit_message.py is in this folder | export PYTHONPATH = ~/myhooks # assuming good_commit_message.py is in this folder | ||
</pre> | </pre> | ||
You can also edit good_commit_message.py to abort commits instead of warning. | You can also edit good_commit_message.py to abort commits instead of warning. |
Revision as of 21:04, 1 August 2011
Commit Message Restrictions
The purpose of these new restrictions implemented by mercurial hook is to avoid commit message without a bug number. We will still allow a small set of special commits like merges and backouts.
This hook will be enabled on mozilla-central and every major branch that directly merges into it, like mozilla-inbound or integration branches, team branches or established project branches.
An example for a passing commit message would be,
Bug 577872 - Create WebM versions of Ogg reftests. r=kinetik
notice the Bug ##### and the r=. Also the review is not checked at the moment, it could be at a feature point and it's strongly encouraged to have it. (please no "my-dog" or "burning"). You also can't commit bustage-fixes without a bug nummber anymore, this is intentional to keep track of the bug which caused it.
Allowed are:
- Commit messages containing "bug" or "b=" followed by a bug number
- Commit messages containing "no bug" (please use this sparingly)
- Commit message indicates backout of a given 12+ digit changeset id, by starting with
(back out|backing out|backed out|backout)( of)? (rev|changeset|cset)s? [0-9a-f]{12}
- Commit message starts with "merge" or "merging" and is actually a merge changeset.
Special exceptions:
- Upadting the NanoJit import in the js/src tree ("Update nanojit-import-rev stamp.")
- Commits by User is "ffxbld", "seabld", "tbirdbld", or "cltbld".
- When the commit is older then some date shortly after the hook has been enabled to allow merges
from other branches. This exception will be lifted after a short period of time (propably a few months) after the hooks was enabled
- You can also specify "ALLOW BAD COMMIT MESSAGES" in the tip (latest) commit message to override
all the restrictions. This is ultra cruel, you should only do this if you have a verry good reason.
Explicitly disallowed:
- Commit messages containing "try: " to avoid unintentional commits that were meant for the try
server.
All this is case case-insensitive.
You can find the source code of this hook at http://hg.mozilla.org/hgcustom/hghooks/file/xxxxx/mozhghooks/xxxxxx.py.
Local setup
It is also possible to use this hook locally so you can already see if there is something wrong with your commit messages before pushing.
Change your .hgrc to include:
[hooks] pretxncommit.good_commit_message = python:goodCommitMessage.hook
You probably need to add good_commit_message to your Python path
export PYTHONPATH = ~/myhooks # assuming good_commit_message.py is in this folder
You can also edit good_commit_message.py to abort commits instead of warning.