Actions

Standard for Git commit messages: Difference between revisions

From LimeSurvey Manual

No edit summary
m (corrected standard for security commit message)
 
(29 intermediate revisions by 7 users not shown)
Line 1: Line 1:
__TOC__
__TOC__


=General overview=
=General overview=


This page describes the standard format of commit messages. Indeed, standard commit messages will ease the automatic generation of releases change logs.
This page describes the standard format of commit messages. Indeed, standard commit messages will make sure that the automatic generation of releases change logs will work properly. '''If you do not follow these rules your contribution(s) might not be properly credited in the change log.
'''


=Rules=
=Rules=
Line 11: Line 11:
* Each commit message is made up of one or more commit blocks
* Each commit message is made up of one or more commit blocks
* A commit block:
* A commit block:
** The first line is the 'Commit Summary' and describes the committed patch in a user friendly way
** The first line is the 'Commit Summary' and describes the committed patch '''in a user friendly way'''
** the following lines begin with the Keyword '''Dev''' and are intended to the developpers team
** The following lines begin with the Keyword '''Dev''' and are intended to the developpers team


<syntaxhighlight lang="php" enclose="div"><Commit type> <commit description> <NEWLINE>
<syntaxhighlight lang="text"><Commit type>: <commit label> <commit description> <NEWLINE>


[ Dev <development details> <NEWLINE> ]
[ Dev <development details> <NEWLINE> ]
Line 20: Line 20:
[ Dev <development details> <NEWLINE> ]
[ Dev <development details> <NEWLINE> ]


<Commit type> <commit description> <NEWLINE>
<Commit type>: <commit label> <commit description> <NEWLINE>


[ Dev <development details> <NEWLINE> ]
[ Dev <development details> <NEWLINE> ]
Line 29: Line 29:


The first word in the commit message gives the commit type:
The first word in the commit message gives the commit type:
* If the commit is about a fix, the commit message must begin with the keyword ''''Fix'''' or ''''Fixed issue''''
* If the commit is about a fix, the commit message must begin with the keyword ''''Fixed issue #<bug ID without leading zeros>'''' or if there is no bug ID just ''''Fixed issue''''
* If the commit is about a change in LS feature, the commit message must begin with the keyword ''''Update feature'''' or ''''Updated feature''''
* If the commit is about a change in LS feature, the commit message must begin with the keyword ''''Updated feature''''
* If the commit is about a change in a translation, the commit message must begin with the keyword ''''Updated translation''''
* If the commit is about a change in a translation, the commit message must begin with the keyword ''''Updated translation''''
* If the commit is about a new feature, the commit message must begin with the keyword ''''New feature''''
* If the commit is about a new feature, the commit message must begin with the keyword ''''New feature''''
* If the commit is about a new translation, the commit message must begin with the keyword ''''New translation''''
* If the commit is about a new translation, the commit message must begin with the keyword ''''New translation''''
* If the commit is not connected to any tracker issue and not of public interest (changelog), just pure development then use ''''Dev''''
==The commit label : security ==
If commit is a security fix, add "[security]" label to first line commit description like in the example below.
Example : <code>Fixed issue #1234: [security] Persistent XSS</code>


==The commit description==
==The commit description==


Following the commit type is the commit description.
Following the commit type is the commit description. This must be a single line (no newline character), and is intended to be used in the generated changelog.


This must be a single line (no newline character), and is intended to be used in the generated changelog.
Ideally it is a text readable by end-users: for instance if you're resolving a bug ticket give the commit a user-friendly description and make sure it describes the problem, not the solution. Remember that an end-user would scan the log that way for a fix for his/her specific problem.
 
Ideally it is a text readable by end-users: for instance if you're resolving a bug ticket which has a very technical description, please use a "end-user friendly description".


==The development details==
==The development details==


Develoment details are added in extra optionnal lines, each one beginning with the keyword ''''Dev''''.
Develoment details are added in extra optional lines, each one beginning with the keyword ''''Dev''''.


==Patches which require multiple commits==
==Patches which require multiple commits==
Line 51: Line 56:
When multiple commits are linked to the same topic (same new feature, same fix, ...), the 'Commit Summary' line of subsequent commits must be the same as the one provided for the first commit.
When multiple commits are linked to the same topic (same new feature, same fix, ...), the 'Commit Summary' line of subsequent commits must be the same as the one provided for the first commit.


Of course the development details can differ.
The development details (line starting with the keyword 'Dev') can differ, of course.


== Examples:==
== Examples==


Example of a simple language file update:
Example of a simple language file update:


<syntaxhighlight lang="php" enclose="div">Updated translation: German</syntaxhighlight>
<syntaxhighlight lang="text">Updated translation: German</syntaxhighlight>
 
Example of a single bug which is fixed in several commits:


<syntaxhighlight lang="php" enclose="div">Fixed issue #2565: Can't access survey more than once on the same browser window
Example of a security fix:


Dev this fixes this bug for survey with tokens.
<syntaxhighlight lang="text">Fixed issue #9762: [security] XSS possible</syntaxhighlight>


Dev When showing a new token (different from the one in session), the previous session is destroyed.</syntaxhighlight>
Example of a single bug which is fixed in several commits:


<syntaxhighlight lang="php" enclose="div">
Commit 1:


Fixed issue #2565: Can't access survey more than once on the same browser window
<syntaxhighlight lang="text">Fixed issue #2565: Can't access survey more than once on the same browser window


Dev this fixes this bug for survey without tokens and without answer preview.
Dev: This fixes this bug for survey with tokens.


Dev Session is destroyed at submit time.
Dev: When showing a new token (different from the one in session), the previous session is destroyed.</syntaxhighlight>


</syntaxhighlight>
Commit 2:


<syntaxhighlight lang="php" enclose="div">Fixed issue #2565: Can't access survey more than once on the same browser window
<syntaxhighlight lang="text">


Dev this fixes this bug for survey without tokens and with answer preview.
Fixed issue #2565: Can't access survey more than once on the same browser window


Dev Session is destroyed when closing the answer preview window or closing the Submit confirmation page.</syntaxhighlight>
Dev: This fixes this bug for survey without tokens and without answer preview.


Example of a single commit containing several fixes each with a Dev comment:
Dev: Session is destroyed at submit time.</syntaxhighlight>


<syntaxhighlight lang="php" enclose="div">Fixed issue #1234: fixed some untranslated strings
Commit 3:


Dev missing call to clang-gT in admin.php
<syntaxhighlight lang="text">Fixed issue #2565: Can't access survey more than once on the same browser window


Fixed issue #2345: fixed a small layout issue in condition editor
Dev: This fixes this bug for survey without tokens and with answer preview.


Dev fixed div HTML elements</syntaxhighlight>
Dev: Session is destroyed when closing the answer preview window or closing the Submit confirmation page.</syntaxhighlight>


=Automatic version info=
Example of a single commit containing several fixes each with a Dev comment:


To have Information about Fileversion, author and commitdate automatically generated on commit. You must do three Things.
<syntaxhighlight lang="text">Fixed issue #1234: Fixed some untranslated strings
* Put the GPL Info and the Id tag into your new or unversionized file. It always looks like this:


<pre>
Dev: Missing call to clang-gT in admin.php


/*
Fixed issue #2345: Fixed a small layout issue in condition editor
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id$
*
*/


</pre>
Dev: Fixed div HTML elements</syntaxhighlight>


The important Tag is the $Id$, which will be replaced with the version info.
[[Category:Development]]
* Assuming you use TortoiseSVN, go to the folder with you newly created or unversioned file and right-click on the file.
** Under the Context-Menu "TortoiseSVN" you will find the Option "Properties". Go to the Properties.
** Now you see an empty list with Options New and Import(others are not clickable).
** Choose "new".
** Choose "svn:keyword" from the Property-Name-Dropdown-Menu and
** type "Id" as value.
** Click OK.
* Now commit the file... and voila! The new file is versionized.

Latest revision as of 16:28, 26 July 2023

General overview

This page describes the standard format of commit messages. Indeed, standard commit messages will make sure that the automatic generation of releases change logs will work properly. If you do not follow these rules your contribution(s) might not be properly credited in the change log.

Rules

Syntax

  • Each commit message is made up of one or more commit blocks
  • A commit block:
    • The first line is the 'Commit Summary' and describes the committed patch in a user friendly way
    • The following lines begin with the Keyword Dev and are intended to the developpers team
<Commit type>: <commit label> <commit description> <NEWLINE>

[ Dev <development details> <NEWLINE> ]

[ Dev <development details> <NEWLINE> ]

<Commit type>: <commit label> <commit description> <NEWLINE>

[ Dev <development details> <NEWLINE> ]

[ Dev <development details> <NEWLINE> ]

The commit type

The first word in the commit message gives the commit type:

  • If the commit is about a fix, the commit message must begin with the keyword 'Fixed issue #<bug ID without leading zeros>' or if there is no bug ID just 'Fixed issue'
  • If the commit is about a change in LS feature, the commit message must begin with the keyword 'Updated feature'
  • If the commit is about a change in a translation, the commit message must begin with the keyword 'Updated translation'
  • If the commit is about a new feature, the commit message must begin with the keyword 'New feature'
  • If the commit is about a new translation, the commit message must begin with the keyword 'New translation'
  • If the commit is not connected to any tracker issue and not of public interest (changelog), just pure development then use 'Dev'

The commit label : security

If commit is a security fix, add "[security]" label to first line commit description like in the example below.

Example : Fixed issue #1234: [security] Persistent XSS

The commit description

Following the commit type is the commit description. This must be a single line (no newline character), and is intended to be used in the generated changelog.

Ideally it is a text readable by end-users: for instance if you're resolving a bug ticket give the commit a user-friendly description and make sure it describes the problem, not the solution. Remember that an end-user would scan the log that way for a fix for his/her specific problem.

The development details

Develoment details are added in extra optional lines, each one beginning with the keyword 'Dev'.

Patches which require multiple commits

When multiple commits are linked to the same topic (same new feature, same fix, ...), the 'Commit Summary' line of subsequent commits must be the same as the one provided for the first commit.

The development details (line starting with the keyword 'Dev') can differ, of course.

Examples

Example of a simple language file update:

Updated translation: German

Example of a security fix:

Fixed issue #9762: [security] XSS possible

Example of a single bug which is fixed in several commits:

Commit 1:

Fixed issue #2565: Can't access survey more than once on the same browser window

Dev: This fixes this bug for survey with tokens.

Dev: When showing a new token (different from the one in session), the previous session is destroyed.

Commit 2:

Fixed issue #2565: Can't access survey more than once on the same browser window

Dev: This fixes this bug for survey without tokens and without answer preview.

Dev: Session is destroyed at submit time.

Commit 3:

Fixed issue #2565: Can't access survey more than once on the same browser window

Dev: This fixes this bug for survey without tokens and with answer preview.

Dev: Session is destroyed when closing the answer preview window or closing the Submit confirmation page.

Example of a single commit containing several fixes each with a Dev comment:

Fixed issue #1234: Fixed some untranslated strings

Dev: Missing call to clang-gT in admin.php

Fixed issue #2345: Fixed a small layout issue in condition editor

Dev: Fixed div HTML elements