tests: prune empty lines and add docstrings
[git-cola.git] / CONTRIBUTING.md
blob3fbbe3f71044156bc4d56340a78119489970bfeb
1 # CONTRIBUTING GUIDELINES
3 Here are some guidelines for people who want to contribute their code
4 to this software.
6 ## Make separate commits for logically separate changes.
8 ## Run the pre-commit checks before committing
10 * `garden check`
12 ## Write tests
14 When adding new features or fixing defects, extend the unit tests to
15 cover the new behavior.  See the `tests/` directory for examples.
16 Find an appropriate test suite and extend it whenever possible.
18 ## Be picky about whitespace
20 This project is very picky about code style.
21 The style here is the standard Python PEP-8 style:
23 https://www.python.org/dev/peps/pep-0008/
25 * Use the `garden fmt` command to format the source code using `cercis`.
27 * Follow the same style as the existing code.
29 * Use 4-space indents.
31 * Use `variable_names_with_underscores` AKA "snake case" naming.
32   No camelCase.  The only exception is when overriding Qt functions.
34 * Do not introduce trailing whitespace.  The "Diff" viewer displays
35   trailing whitespace in red, or you can use "git diff --check".
37 * If you use SublimeText, configure `newline_at_eof_on_save` to true.
39 * Avoid "No newline at end of file"
40   [in your diffs](https://robots.thoughtbot.com/no-newline-at-end-of-file).
42 ## Describe your changes well.
44 The first line of the commit message should be a short description (50
45 characters is the soft limit, see DISCUSSION in git-commit(1)), and
46 should skip the full stop.  It is also conventional in most cases to
47 prefix the first line with "area: " where the area is a filename or
48 identifier for the general area of the code being modified, e.g.
50 * push: allow pushing to multiple remotes
52 * grep: allow passing in command-line arguments
54 If in doubt which identifier to use, run "git log --no-merges" on the
55 files you are modifying to see the current conventions.
57 The body should provide a meaningful commit message, which:
59 * explains the problem the change tries to solve, in other words,
60   what is wrong with the current code without the change.
62 * justifies the way the change solves the problem, in other words,
63   why the result with the change is better.
65 * alternate solutions considered but discarded, if any.
67 Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
68 instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
69 to do frotz", as if you are giving orders to the codebase to change
70 its behaviour.  Try to make sure your explanation can be understood
71 without external resources. Instead of giving a URL to a mailing list
72 archive, summarize the relevant points of the discussion.
74 If you like, you can put extra tags at the end:
76 * "Reported-by:" is used to credit someone who found the bug that
77   the patch attempts to fix.
79 * "Acked-by:" says that the person who is more familiar with the area
80   the patch attempts to modify liked the patch.
82 * "Reviewed-by:", unlike the other tags, can only be offered by the
83   reviewer and means that she is completely satisfied that the patch
84   is ready for application.  It is usually offered only after a
85   detailed review.
87 * "Tested-by:" is used to indicate that the person applied the patch
88   and found it to have the desired effect.
90 You can also create your own tag or use one that's in common usage
91 such as "Thanks-to:", "Based-on-patch-by:", or "Helped-by:".
93 ## Sign your work
95 To improve tracking of who did what, we've borrowed the
96 "sign-off" procedure from the Linux kernel project on patches
97 that are being emailed around.  Although core Git is a lot
98 smaller project it is a good discipline to follow it.
100 The sign-off is a simple line at the end of the explanation for
101 the patch, which certifies that you wrote it or otherwise have
102 the right to pass it on as an open-source patch.  The rules are
103 pretty simple: if you can certify the below:
105 Developer's Certificate of Origin 1.1
107 By making a contribution to this project, I certify that:
109 (a) The contribution was created in whole or in part by me and I
110     have the right to submit it under the open source license
111     indicated in the file; or
113 (b) The contribution is based upon previous work that, to the best
114     of my knowledge, is covered under an appropriate open source
115     license and I have the right under that license to submit that
116     work with modifications, whether created in whole or in part
117     by me, under the same open source license (unless I am
118     permitted to submit under a different license), as indicated
119     in the file; or
121 (c) The contribution was provided directly to me by some other
122     person who certified (a), (b) or (c) and I have not modified
123     it.
125 (d) I understand and agree that this project and the contribution
126 are public and that a record of the contribution (including all
127 personal information I submit with it, including my sign-off) is
128 maintained indefinitely and may be redistributed consistent with
129 this project or the open source license(s) involved.
131 then you just add a line saying
133 Signed-off-by: Random J Developer <random@developer.example.org>
135 This line can be automatically added by Git if you run the git-commit
136 command with the -s option, or using the `Ctrl+i` hotkey in git-cola's
137 commit message editor.
139 Notice that you can place your own Signed-off-by: line when
140 forwarding somebody else's patch with the above rules for
141 D-C-O.  Indeed you are encouraged to do so.  Do not forget to
142 place an in-body "From: " line at the beginning to properly attribute
143 the change to its true author (see (2) above).
145 Also notice that a real name is used in the Signed-off-by: line. Please
146 don't hide your real name.
148 ## Reporting Bugs
150 Please read [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html)
151 for some general tips on bug reporting.
153 ## Internationalization and Localization
155 Git Cola is translated to several languages.  When strings are presented to
156 the user they must use the `N_('<string>')` function so that `<string>` is
157 translated into a localized string.
159 The translation message files are the `*.po` files in the `cola/i18n/` directory.
160 Adding a new translation entails creating a new language-specific `.po` file.
162 Please note - it is preferred that git command jargon will be left untranslated.
164 When new (untranslated) strings are added to the project, the `git-cola.pot`
165 base template and the language-specific message files need to be updated with
166 the new strings.
168 To regenerate `git-cola.pot` and update `.po` files with new strings run:
170     garden pot
172 This will update `.po` files with untranslated strings which translators can
173 use to translate `git-cola`.
175 Untranslated strings are denoted by an empty "" string.
177 Alternate translations can be tested by setting `$LANG` when running, e.g.
179     env LANG=zh_TW ./bin/git-cola
181 The [Gettext Language Code](https://www.gnu.org/software/gettext/manual/gettext.html#Language-Codes)
182 corresponds to the `.po` filename.  Country-specific suffixes use the
183 [Gettext country code](https://www.gnu.org/software/gettext/manual/gettext.html#Country-Codes).
185 We happily welcome pull requests with improvements to `git-cola`'s translations.
187 ## Fork the repo on Github and create a pull request.