1,848
edits
(→Guidelines: document commonly used "test:" prefix) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
For more options, see [https://www.mercurial-scm.org/repo/hg/help/log the Mercurial manual]. | For more options, see [https://www.mercurial-scm.org/repo/hg/help/log the Mercurial manual]. | ||
== Examples == | == Examples == | ||
Line 162: | Line 52: | ||
</pre> | </pre> | ||
=== One line | === One line examples === | ||
This examples are the rare cases where only one file is modified and the change is simple enough: | This examples are the rare cases where only one file is modified and the change is simple enough: | ||
Line 180: | Line 70: | ||
uigetfile.m: allow path names as input arg (bug #48828) | uigetfile.m: allow path names as input arg (bug #48828) | ||
== Guidelines == | |||
The general structure of a commit message should be clear from the examples: | |||
* After the first line, leave one blank line. | |||
* Do not end the first line with a period (full stop). | |||
* Keep it short, no longer than 80 characters. | |||
* Add the bug number, e.g. <code>(bug #12345)</code>, where applicable. | |||
* Use prefixes where applicable: | |||
** <code>build:</code> for changes to the build system, for example autoconf or automake files. | |||
** <code>doc:</code> for changes to the documentation. | |||
** <code>gui:</code> for changes to the graphical user interface. | |||
** <code>maint:</code> for reorganization of the sources that do not change the source. Regular merge commits are a prominent example. | |||
** <code>test:</code> for changes to [[Tests]] only, e.g. new/removed BISTs, changed tolerances, etc. | |||
=== Wording === | |||
{| class="wikitable" | |||
! bad | |||
! good | |||
|- | |||
| style="color:darkred;" | "Added function" | |||
| style="color:green;" | "New function" | |||
|- | |||
| style="color:darkred;" | "Changed to return retval" | |||
| style="color:green;" | "Return retval" | |||
|- | |||
| style="color:darkred;" | "Fixed bug" | |||
| style="color:green;" | Write '''what''' has changed. | |||
|} | |||
The commit message should describe '''what''' was changed, not '''why''' it was changed. Any explanations should appear as comments in the code, particularly if there is something that might not be obvious to someone reading it later. | |||
=== Body of the commit message === | |||
Each individual file changed by a commit must have its changes enumerated. For changes affecting specific C++ functions, each function name is listed in parentheses. For example | |||
* file.cc (class1::function1): Add something. | |||
(function2, function3): Delete something else. | |||
For changes affecting specific Octave built-ins, each built-in name is listed in parentheses with an "F" prefix, an implementation detail. For example | |||
* data.cc (Fcolumns): Return columns. | |||
When the same change is applied to a series of files, or to a set of functions in a single file, the file or function names may be grouped to shorten the commit message. For example: | |||
* file1.cc, file2.cc, file3.cc, file4.cc: Include <sys/types.h>. | |||
* memory.cc (function1, function2, function3): Throw error if empty. | |||
Each line of the commit message body should also be kept under 80 columns. The GNU standards recommend starting a new line for each parenthesized function, but if the line is short enough, we often avoid an extra newline. For example | |||
* file.cc (function1): Add an option. (function2): Add another option. | |||
Only the last file name component is typically needed, since most files have unique names across the entire repository. One notable exception are the {{codeline|module.mk}} files in every directory, they should include the complete directory and file name. For example | |||
* doc/interpreter/module.mk (dist_man_MANS): Include foo.1 in the list. | |||
Avoid abbreviating or using shell globs or patterns when listing the names of files affected by a change, even when they have the same name with different file extensions. For example | |||
* oct-fftw.cc, oct-fftw.h (octave_fftw_version): New function. | |||
For m-file and Fortran sources, the function name can be omitted if the file contains only one function. For changes outside of functions or classes, of course the parenthetical (function) or (class::function) specifiers can also be omitted. | |||
[[Category:Development]] | [[Category:Development]] |