User:Evilpie/commit-restrictions: Difference between revisions

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


Line 19: 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
* 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 messages that start with "merge" or "merging" and are actually for a merge changeset.
  (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:
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
* 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.
  from other branches. This exception will be lifted after a short period of time  
* 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.
  (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:
Explicitly disallowed:
* Commit messages containing "try: " to avoid unintentional commits that were meant for the try
* Commit messages containing "try: " to avoid unintentional commits that were meant for the try server.
  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 44: 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.


Change your .hgrc to include:
Change your .hgrc to include:
<tt>
<pre>
  [hooks]
[hooks]
  pretxncommit.good_commit_message = python:goodCommitMessage.hook
pretxncommit.commit = python:commit-message.hook
</tt>
</pre>
You probably need to add good_commit_message to your Python path
You probably need to add commit-message.py to your Python path.
<tt>  
<pre>
    export PYTHONPATH = ~/myhooks # assuming good_commit_message.py is in this folder
export PYTHONPATH = ~/myhooks # assuming commit-message.py is in this folder
</tt>
</pre>
You can also edit good_commit_message.py to abort commits instead of warning.
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.

Latest revision as of 19:46, 16 August 2011

Commit Message Restrictions

The purpose of these new restrictions, implemented via a mercurial hook, is to prevent commit messages 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, such as 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= indicating the reviewer. Also the reviewer is not checked at the moment, it could be at a 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 number 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 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 messages that start with "merge" or "merging" and are actually for a merge changeset.

Special exceptions:

  • Updating the NanoJit import in the js/src tree ("Update nanojit-import-rev stamp.")
  • 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 (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 an extreme measure, so you should only do this if you have a very good reason.

Explicitly disallowed:

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

All tests for allowed or excluded messages are 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 see if there is something wrong with your commit messages before pushing.

Change your .hgrc to include:

[hooks]
pretxncommit.commit = python:commit-message.hook

You probably need to add commit-message.py to your Python path.

export PYTHONPATH = ~/myhooks # assuming commit-message.py is in this folder

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.