User:Evilpie/commit-restrictions: Difference between revisions

 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Commit Message Restrictions ==
== Commit Message Restrictions ==


The purpose of these new restrictions implemented by mercurial hook is to avoid commit message
The purpose of these new restrictions, implemented via a mercurial hook, is to prevent commit messages
without a bug number. We will still allow a small set of special commits like merges and backouts.
that do not have a bug number. We will still allow a small set of special commits lacking bugs numbers, like merges and backouts.


This hook will be enabled on mozilla-central and every major branch that directly merges into it,
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.
such as mozilla-inbound or integration branches, team branches, or established project branches.


An example for a passing commit message would be,
An example for a passing commit message would be,
<pre>Bug 577872 - Create WebM versions of Ogg reftests. r=kinetik</pre>
<pre>Bug 577872 - Create WebM versions of Ogg reftests. r=kinetik</pre>
notice the Bug ##### and the r=. Also the review is not checked at the moment, it could be at a
notice the <tt>Bug #####</tt> and the <tt>r=</tt> indicating the reviewer. Also the reviewer 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").
future time and you are strongly encouraged to include it. (Please no fake reviewers like "my-dog" or "burning").
You also can't commit bustage-fixes without a bug nummber anymore, this is intentional to keep track
You also can't commit bustage-fixes without a bug number anymore. This is intentional to keep track
of the bug which caused it.
of the bug which caused it.


Line 17: Line 17:
* Commit messages containing "bug" or "b=" followed by a bug number
* Commit messages containing "bug" or "b=" followed by a bug number
* Commit messages containing "no bug" (please use this sparingly)
* 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 indicating backout of a given 12+ digit changeset ID, 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.
* Commit messages that start with "merge" or "merging" and are actually for a merge changeset.


Special exceptions:
Special exceptions:
* Upadting the NanoJit import in the js/src tree ("Update nanojit-import-rev stamp.")
* Updating the NanoJit import in the js/src tree ("Update nanojit-import-rev stamp.")
* Commits by User is "ffxbld", "seabld", "tbirdbld", or "cltbld".
* Commits by the special users "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
* 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 (probably a few months) after the hooks is 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.
* You can also specify "ALLOW BAD COMMIT MESSAGES" in the tip (latest) commit message to override all the restrictions. This is an extreme measure, so you should only do this if you have a very good reason.


Explicitly disallowed:
Explicitly disallowed:
* Commit messages containing "try: " to avoid unintentional commits that were meant for the try server.
* Commit messages containing "try: " to avoid unintentional commits that were meant for the try server.


All this is case case-insensitive.
All tests for allowed or excluded messages are case case-insensitive.


You can find the source code of this hook at  
You can find the source code of this hook at  
Line 36: Line 36:
=== Local setup ===
=== Local setup ===


It is also possible to use this hook locally so you can already see if there is something wrong
It is also possible to use this hook locally so you can see if there is something wrong
with your commit messages before pushing.
with your commit messages before pushing.


Line 42: Line 42:
<pre>
<pre>
[hooks]
[hooks]
pretxncommit.good_commit_messages = python:good_commit_messages.hook
pretxncommit.commit = python:commit-message.hook
</pre>
</pre>
You probably need to add good_commit_messages.py to your Python path
You probably need to add commit-message.py to your Python path.
<pre>
<pre>
export PYTHONPATH = ~/myhooks # assuming good_commit_messages.py is in this folder
export PYTHONPATH = ~/myhooks # assuming commit-message.py is in this folder
</pre>
</pre>
You can also edit good_commit_messages.py to abort commits instead of warning. Search for <pre>fail not warn</pre> in the the file and change <pre>0</pre> to <pre>1</pre>
You can also edit commit-message.py to abort commits instead of warning. Search for "to fail not warn change to 1" (without the quotes) in the the file and change 0 to 1.
canmove, Confirmed users
1,953

edits