Commit Policy/ru: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''Russian''' [[Commit Policy|English]] [[Commit Policy SimplifiedChinese|简体中文]]
[[Category:Developing Qt::Guidelines]]<br />'''Russian''' [[Commit_Policy|English]] [[Commit_Policy_SimplifiedChinese|简体中文]]


=Политика внесения изменений=
= Политика внесения изменений =


==Правила==
== Правила ==


Далее описаны главные правила для создания и публикации изменений в любые репозитории Qt. Как обычно в Qt, ни одно из этих правил не является абсолютно верным, но вы будете обьектом насмешек если нарушите их без обьективной причины.
Далее описаны главные правила для создания и публикации изменений в любые репозитории Qt. Как обычно в Qt, ни одно из этих правил не является абсолютно верным, но вы будете обьектом насмешек если нарушите их без обьективной причины.


# Если вы добавляете новую функцию/класс:
#. Если вы добавляете новую функцию/класс:<br />## Убедитесь в том, что все задокументировано правильно.<br />## Следуйте [[Api_Design_Principles]]. Обсудите и сверьте имена функций/классов с другими Qt разработчиками (conduct API reviews).<br /># Весь код должен соответствовать [[Coding_Conventions]].<br /># Для программирования GUI, следуйте &quot;руководству по стилю&amp;quot;:http://techbase.kde.org/Projects/Usability/HIG (да, это от KDE), следуйте советам по переводу &quot;Qt Creator&amp;quot;:http://developer.qt.nokia.com/wiki/Qt_Creator_Translation_Page и избеайте &quot;ошибки локализации&amp;quot;:http://techbase.kde.org/Development/Tutorials/Localization/i18n_Mistakes.<br /># Убедитесь что ваши изменения компилируются и работают на всех платформах.<br /># Проверьте что нет никакой регрессии в модульных тестах (для большей информации взляните на [[Qt_Autotests_Environment]]).<br /># Пишите новые модульные тесты для багов которые вы устранили или вами добавленного нового функционала.<br /># Оформляйте новый или изменённый вами код в соответствии с [[Qt_Coding_Style]].<br /># Produce commits which facilitate reviews and contribute to a useful history which can be read, searched, annotated and cherry-picked. Here are some hints:<br />## Make minimal and atomic commits. That means that each commit should contain exactly one self-contained change - don't mix unrelated changes, and don't create inconsistent states. Never &quot;hide&amp;quot; unrelated fixes in bigger commits. Make coding style fixes only in exactly the lines which contain the functional changes, and comment fixes only when they relate to the change - the rest is for a separate commit.<br />## Write descriptive commit messages. Make them self-contained, so people don't have to research the historical context to make sense of them. Conversely, don't put unnecessary trivia into them. Tell ''why'' you changed something unless it is completely self-evident. Use the &quot;Qt commit template&amp;quot;:http://qt.gitorious.org/qt/qt/blobs/697e236c096d62137fdd155f5ef8d72a26b8636b/.commit-template: Follow the summary + description message style and use pseudo-headers to reference JIRA issues, reviewers, etc. and consider the &quot;generic Git commit message guidelines&amp;quot;:http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html.<br />## Commit often. Use &lt;code&amp;gt;git gui&amp;lt;/code&amp;gt; and &lt;code&amp;gt;git rebase -i&amp;lt;/code&amp;gt; extensively to get your history into shape.<br />## Avoid unnecessary merges. Use &lt;code&amp;gt;git pull —rebase&amp;lt;/code&amp;gt; unless you have an unpushed &quot;proper&amp;quot; merge.<br /># Get a review from somebody who knows the code before you publish. If there is no candidate yet, introduce somebody to the code. Note that pushing to your private clone does '''not''' count as publishing and is a perfectly valid way to solicit a review or make a backup of a work in progress.<br /># Don't commit anything you don't understand. &quot;Somehow it suddenly works&amp;quot; is not acceptable. Reverting when a proper fix would be possible is admitting defeat. ;)<br /># Review your changes before you push. &lt;code&amp;gt;git log —stat&amp;lt;/code&amp;gt;, &lt;code&amp;gt;git log <s>p&amp;lt;/code&amp;gt; and &lt;code&amp;gt;gitk&amp;lt;/code&amp;gt; are your friends.<br /># Don't fight the git pre-receive hooks. See below.<br /># And most importantly: use your brain before hitting &lt;code&amp;gt;&lt;enter&amp;gt;&lt;/code&amp;gt;.
## Убедитесь в том, что все задокументировано правильно.
<br />h2. The pre-receive Hooks
## Следуйте [[API Design Principles|<span class="caps">API</span>_Design_Principles]]. Обсудите и сверьте имена функций/классов с другими Qt разработчиками (conduct <span class="caps">API</span> reviews).
<br />Our internal git repositories have various pre-receive hooks installed which ensure some minimal quality standards and legal safety. The sanitizer script (without the privacy check) is available from the &quot;devscripts repository&amp;quot;:https://qt.gitorious.org/qt-labs/devscripts. The checks are:
# Весь код должен соответствовать [[Coding Conventions|Coding_Conventions]].
<br /># The privacy check. It tries to ensure that no real names are published without explicit consent. A side effect is that it will complain about invalid committer information, which is Good ™. Valid addresses from external contributors are added to a whitelist; that process is semi-automated.<br /># The line ending check. We are developing in a heterogeneous environment with both Unix and Windows machines. Therefore it is imperative to have all files in the repository in the canonical LF-only format. Windows users need to set the git option &lt;code&amp;gt;core.autocrlf&amp;lt;/code&amp;gt; to &lt;code&amp;gt;true&amp;lt;/code&amp;gt; to automatically get CRLF line endings which are suitable for the native tools.<br /># Conflict marker check. Unless you are adding a text file which contains the patterns on purpose, you most probably botched a merge/rebase.<br /># Generated file check. Don't commit generated files</s> they bloat the repository and create spurious changes. If a file is generated but you don't know how to automate the build process, ask an expert.<br /># Check for project/config files of alien build systems. As we are using qmake, these will in most cases fall under the &quot;generated file&amp;quot; rule anyway.<br /># Big file addition check. Think three times whether you '''really''' need that huge media file, test binary or screenshot. As we are using git, such mistakes are not correctable - once you added a huge file, everyone who clones the repository will have to pay for it with network traffic and disk space for all times. Source code files are exempt from the check at all; for the rest it is a bit paranoid (it will complain about anything bigger than 50 KiB or an instantaneous file growth over 150% if the file is bigger than 20 KiB).<br /># Huge file addition check. If you trigger that one, you almost certainly did something wrong.<br /># Work In Progress push check. This is meant to avoid that you accidentally push something you marked for later cleanup. It checks for the strings &quot;WIP&amp;quot; and &quot;''''''*&quot; in the summary line and for an empty Reviewed-by line. This check is disabled in the local post-commit hook for obvious reasons.<br /># Check for mixing whitespace and non-whitespace changes. A commit may contain only whitespace changes or &quot;proper&amp;quot; changes (with whitespace cleanups only on already changed lines, and, as an exception, additions and removals of empty lines). This helps to ensure the usefulness of &lt;code&amp;gt;git blame&amp;lt;/code&amp;gt; (note that a clean history is better than using &lt;code&amp;gt;git blame <s>w&amp;lt;/code&amp;gt;, as the latter will also hide significant whitespace changes). (currently advisory only)<br /># Some simple coding style checks. (currently advisory only)
# Для программирования <span class="caps">GUI</span>, следуйте [http://techbase.kde.org/Projects/Usability/HIG руководству по стилю] ''[techbase.kde.org]'' (да, это от <span class="caps">KDE</span>), следуйте советам по переводу [http://developer.qt.nokia.com/wiki/Qt_Creator_Translation_Page Qt Creator] ''[developer.qt.nokia.com]'' и избеайте [http://techbase.kde.org/Development/Tutorials/Localization/i18n_Mistakes ошибки локализации] ''[techbase.kde.org]''.
<br />The checks can be overridden on a case by case basis when needed. Don't even think about overriding any of them unless you have a '''really''' good reason. &quot;I need to get this done '''now'''&quot; is not a valid reason. Neither is &quot;I cannot be bothered to understand what it wants from me&amp;quot;. If there is any doubt, discuss alternatives with somebody appropriate.
# Убедитесь что ваши изменения компилируются и работают на всех платформах.
<br />Each error/warning message mentions the key needed to override it. Note that there is only one key per entire category, so make sure to check all reports before you apply the override.
# Проверьте что нет никакой регрессии в модульных тестах (для большей информации взляните на [[Qt Autotests Environment|Qt_Autotests_Environment]]).
<br />The recommended override command is printed by the hook itself. '''Don't''' export the environment variable in the current shell, as you will inevitably forget to unset it again and thus disarm the hooks semi-permanently.
# Пишите новые модульные тесты для багов которые вы устранили или вами добавленного нового функционала.
<br />For the overrides to work, you need to tell ssh to forward the GIT_PUSH environment variable to the git server. If you don't have an ssh config file yet, create one. It is probably wise to put a &lt;code&amp;gt;Host scm.dev*&lt;/code&amp;gt; line in front of the &lt;code&amp;gt;SendEnv&amp;lt;/code&amp;gt; line to restrict the scope of the setting. Under Windows, the file will be usually located in &lt;code&amp;gt;&quot;C:and Settingslt;user&amp;gt;sh\config&amp;quot;&lt;/code&amp;gt;, though apparently it is possible to set HOME like under Unix to change ssh's behavior.
# Оформляйте новый или изменённый вами код в соответствии с [[Qt Coding Style|Qt_Coding_Style]].
<br />It is possible to run most of the checks locally before attempting to push</s> this is especially useful for the checks which are currently advisory only. See the &lt;code&amp;gt;devtools/shell/git_post_commit_hook&amp;lt;/code&amp;gt; script (it contains installation instructions).
# Produce commits which facilitate reviews and contribute to a useful history which can be read, searched, annotated and cherry-picked. Here are some hints:
## Make minimal and atomic commits. That means that each commit should contain exactly one self-contained change – don’t mix unrelated changes, and don’t create inconsistent states. Never “hide” unrelated fixes in bigger commits. Make coding style fixes only in exactly the lines which contain the functional changes, and comment fixes only when they relate to the change – the rest is for a separate commit.
## Write descriptive commit messages. Make them self-contained, so people don’t have to research the historical context to make sense of them. Conversely, don’t put unnecessary trivia into them. Tell ''why'' you changed something unless it is completely self-evident. Use the [http://qt.gitorious.org/qt/qt/blobs/697e236c096d62137fdd155f5ef8d72a26b8636b/.commit-template Qt commit template] ''[qt.gitorious.org]'': Follow the summary + description message style and use pseudo-headers to reference <span class="caps">JIRA</span> issues, reviewers, etc. and consider the [http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html generic Git commit message guidelines] ''[tbaggery.com]''.
## Commit often. Use <code>git gui</code> and <code>git rebase -i</code> extensively to get your history into shape.
## Avoid unnecessary merges. Use <code>git pull —rebase</code> unless you have an unpushed “proper” merge.
# Get a review from somebody who knows the code before you publish. If there is no candidate yet, introduce somebody to the code. Note that pushing to your private clone does '''not''' count as publishing and is a perfectly valid way to solicit a review or make a backup of a work in progress.
# Don’t commit anything you don’t understand. “Somehow it suddenly works” is not acceptable. Reverting when a proper fix would be possible is admitting defeat. <span class="smiley">;)</span>
# Review your changes before you push. <code>git log —stat</code>, <code>git log -p</code> and <code>gitk</code> are your friends.
# Don’t fight the git pre-receive hooks. See below.
# And most importantly: use your brain before hitting <code>&lt;enter&gt;</code>.
 
==The pre-receive Hooks==
 
Our internal git repositories have various pre-receive hooks installed which ensure some minimal quality standards and legal safety. The sanitizer script (without the privacy check) is available from the [https://qt.gitorious.org/qt-labs/devscripts devscripts repository] ''[qt.gitorious.org]''. The checks are:
 
# The privacy check. It tries to ensure that no real names are published without explicit consent. A side effect is that it will complain about invalid committer information, which is Good ™. Valid addresses from external contributors are added to a whitelist; that process is semi-automated.
# The line ending check. We are developing in a heterogeneous environment with both Unix and Windows machines. Therefore it is imperative to have all files in the repository in the canonical LF-only format. Windows users need to set the git option <code>core.autocrlf</code> to <code>true</code> to automatically get <span class="caps">CRLF</span> line endings which are suitable for the native tools.
# Conflict marker check. Unless you are adding a text file which contains the patterns on purpose, you most probably botched a merge/rebase.
# Generated file check. Don’t commit generated files they bloat the repository and create spurious changes. If a file is generated but you don’t know how to automate the build process, ask an expert.
# Check for project/config files of alien build systems. As we are using qmake, these will in most cases fall under the “generated file” rule anyway.
# Big file addition check. Think three times whether you '''really''' need that huge media file, test binary or screenshot. As we are using git, such mistakes are not correctable once you added a huge file, everyone who clones the repository will have to pay for it with network traffic and disk space for all times. Source code files are exempt from the check at all; for the rest it is a bit paranoid (it will complain about anything bigger than 50 KiB or an instantaneous file growth over 150% if the file is bigger than 20 KiB).
# Huge file addition check. If you trigger that one, you almost certainly did something wrong.
# Work In Progress push check. This is meant to avoid that you accidentally push something you marked for later cleanup. It checks for the strings “<span class="caps">WIP</span>” and ***” in the summary line and for an empty Reviewed-by line. This check is disabled in the local post-commit hook for obvious reasons.
# Check for mixing whitespace and non-whitespace changes. A commit may contain only whitespace changes or “proper” changes (with whitespace cleanups only on already changed lines, and, as an exception, additions and removals of empty lines). This helps to ensure the usefulness of <code>git blame</code> (note that a clean history is better than using <code>git blame -w</code>, as the latter will also hide significant whitespace changes). (currently advisory only)
# Some simple coding style checks. (currently advisory only)
 
The checks can be overridden on a case by case basis when needed. Don’t even think about overriding any of them unless you have a '''really''' good reason. “I need to get this done '''now'''is not a valid reason. Neither is “I cannot be bothered to understand what it wants from me”. If there is any doubt, discuss alternatives with somebody appropriate.
 
Each error/warning message mentions the key needed to override it. Note that there is only one key per entire category, so make sure to check all reports before you apply the override.
 
The recommended override command is printed by the hook itself. '''Don’t''' export the environment variable in the current shell, as you will inevitably forget to unset it again and thus disarm the hooks semi-permanently.
 
For the overrides to work, you need to tell ssh to forward the <span class="caps">GIT</span>_PUSH environment variable to the git server. If you don’t have an ssh config file yet, create one. It is probably wise to put a <code>Host scm.dev*</code> line in front of the <code>SendEnv</code> line to restrict the scope of the setting. Under Windows, the file will be usually located in <code>“C:\Documents and Settings\&lt;user&gt;\.ssh\config”</code>, though apparently it is possible to set <span class="caps">HOME</span> like under Unix to change ssh’s behavior.
 
It is possible to run most of the checks locally before attempting to push this is especially useful for the checks which are currently advisory only. See the <code>devtools/shell/git_post_commit_hook</code> script (it contains installation instructions).
 
===Categories:===
 
* [[:Category:Developing-Qt|Developing Qt]]
** [[:Category:Developing-Qt::Guidelines|Guidelines]]

Revision as of 11:46, 24 February 2015


Russian English 简体中文

Политика внесения изменений

Правила

Далее описаны главные правила для создания и публикации изменений в любые репозитории Qt. Как обычно в Qt, ни одно из этих правил не является абсолютно верным, но вы будете обьектом насмешек если нарушите их без обьективной причины.

  1. . Если вы добавляете новую функцию/класс:
    ## Убедитесь в том, что все задокументировано правильно.
    ## Следуйте Api_Design_Principles. Обсудите и сверьте имена функций/классов с другими Qt разработчиками (conduct API reviews).
    # Весь код должен соответствовать Coding_Conventions.
    # Для программирования GUI, следуйте "руководству по стилю&quot;:http://techbase.kde.org/Projects/Usability/HIG (да, это от KDE), следуйте советам по переводу "Qt Creator&quot;:http://developer.qt.nokia.com/wiki/Qt_Creator_Translation_Page и избеайте "ошибки локализации&quot;:http://techbase.kde.org/Development/Tutorials/Localization/i18n_Mistakes.
    # Убедитесь что ваши изменения компилируются и работают на всех платформах.
    # Проверьте что нет никакой регрессии в модульных тестах (для большей информации взляните на Qt_Autotests_Environment).
    # Пишите новые модульные тесты для багов которые вы устранили или вами добавленного нового функционала.
    # Оформляйте новый или изменённый вами код в соответствии с Qt_Coding_Style.
    # Produce commits which facilitate reviews and contribute to a useful history which can be read, searched, annotated and cherry-picked. Here are some hints:
    ## Make minimal and atomic commits. That means that each commit should contain exactly one self-contained change - don't mix unrelated changes, and don't create inconsistent states. Never "hide&quot; unrelated fixes in bigger commits. Make coding style fixes only in exactly the lines which contain the functional changes, and comment fixes only when they relate to the change - the rest is for a separate commit.
    ## Write descriptive commit messages. Make them self-contained, so people don't have to research the historical context to make sense of them. Conversely, don't put unnecessary trivia into them. Tell why you changed something unless it is completely self-evident. Use the "Qt commit template&quot;:http://qt.gitorious.org/qt/qt/blobs/697e236c096d62137fdd155f5ef8d72a26b8636b/.commit-template: Follow the summary + description message style and use pseudo-headers to reference JIRA issues, reviewers, etc. and consider the "generic Git commit message guidelines&quot;:http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html.
    ## Commit often. Use <code&gt;git gui&lt;/code&gt; and <code&gt;git rebase -i&lt;/code&gt; extensively to get your history into shape.
    ## Avoid unnecessary merges. Use <code&gt;git pull —rebase&lt;/code&gt; unless you have an unpushed "proper&quot; merge.
    # Get a review from somebody who knows the code before you publish. If there is no candidate yet, introduce somebody to the code. Note that pushing to your private clone does not count as publishing and is a perfectly valid way to solicit a review or make a backup of a work in progress.
    # Don't commit anything you don't understand. "Somehow it suddenly works&quot; is not acceptable. Reverting when a proper fix would be possible is admitting defeat. ;)
    # Review your changes before you push. <code&gt;git log —stat&lt;/code&gt;, <code&gt;git log p&lt;/code&gt; and <code&gt;gitk&lt;/code&gt; are your friends.
    # Don't fight the git pre-receive hooks. See below.
    # And most importantly: use your brain before hitting <code&gt;<enter&gt;</code&gt;.


h2. The pre-receive Hooks
Our internal git repositories have various pre-receive hooks installed which ensure some minimal quality standards and legal safety. The sanitizer script (without the privacy check) is available from the "devscripts repository&quot;:https://qt.gitorious.org/qt-labs/devscripts. The checks are:
# The privacy check. It tries to ensure that no real names are published without explicit consent. A side effect is that it will complain about invalid committer information, which is Good ™. Valid addresses from external contributors are added to a whitelist; that process is semi-automated.
# The line ending check. We are developing in a heterogeneous environment with both Unix and Windows machines. Therefore it is imperative to have all files in the repository in the canonical LF-only format. Windows users need to set the git option <code&gt;core.autocrlf&lt;/code&gt; to <code&gt;true&lt;/code&gt; to automatically get CRLF line endings which are suitable for the native tools.
# Conflict marker check. Unless you are adding a text file which contains the patterns on purpose, you most probably botched a merge/rebase.
# Generated file check. Don't commit generated files
they bloat the repository and create spurious changes. If a file is generated but you don't know how to automate the build process, ask an expert.
# Check for project/config files of alien build systems. As we are using qmake, these will in most cases fall under the "generated file&quot; rule anyway.
# Big file addition check. Think three times whether you really' need that huge media file, test binary or screenshot. As we are using git, such mistakes are not correctable - once you added a huge file, everyone who clones the repository will have to pay for it with network traffic and disk space for all times. Source code files are exempt from the check at all; for the rest it is a bit paranoid (it will complain about anything bigger than 50 KiB or an instantaneous file growth over 150% if the file is bigger than 20 KiB).
# Huge file addition check. If you trigger that one, you almost certainly did something wrong.
# Work In Progress push check. This is meant to avoid that you accidentally push something you marked for later cleanup. It checks for the strings "WIP&quot; and "'
*" in the summary line and for an empty Reviewed-by line. This check is disabled in the local post-commit hook for obvious reasons.
# Check for mixing whitespace and non-whitespace changes. A commit may contain only whitespace changes or "proper&quot; changes (with whitespace cleanups only on already changed lines, and, as an exception, additions and removals of empty lines). This helps to ensure the usefulness of <code&gt;git blame&lt;/code&gt; (note that a clean history is better than using <code&gt;git blame w&lt;/code&gt;, as the latter will also hide significant whitespace changes). (currently advisory only)
# Some simple coding style checks. (currently advisory only)
The checks can be overridden on a case by case basis when needed. Don't even think about overriding any of them unless you have a really good reason. "I need to get this done now" is not a valid reason. Neither is "I cannot be bothered to understand what it wants from me&quot;. If there is any doubt, discuss alternatives with somebody appropriate.
Each error/warning message mentions the key needed to override it. Note that there is only one key per entire category, so make sure to check all reports before you apply the override.
The recommended override command is printed by the hook itself. Don't export the environment variable in the current shell, as you will inevitably forget to unset it again and thus disarm the hooks semi-permanently.
For the overrides to work, you need to tell ssh to forward the GIT_PUSH environment variable to the git server. If you don't have an ssh config file yet, create one. It is probably wise to put a <code&gt;Host scm.dev*</code&gt; line in front of the <code&gt;SendEnv&lt;/code&gt; line to restrict the scope of the setting. Under Windows, the file will be usually located in <code&gt;"C:and Settingslt;user&gt;sh\config&quot;</code&gt;, though apparently it is possible to set HOME like under Unix to change ssh's behavior.
It is possible to run most of the checks locally before attempting to push
this is especially useful for the checks which are currently advisory only. See the <code&gt;devtools/shell/git_post_commit_hook&lt;/code&gt; script (it contains installation instructions).