models: avoid resetting state in set_worktree()
[git-cola.git] / CONTRIBUTING.md
blob3cda4b0e3ee4caf295d412e995a93dc061c6981d
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 * `make 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 http://www.python.org/dev/peps/pep-0008/
25 * Use the `make format` command to format the source code using `black`.
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 https://robots.thoughtbot.com/no-newline-at-end-of-file
41 ## Describe your changes well.
43 The first line of the commit message should be a short description (50
44 characters is the soft limit, see DISCUSSION in git-commit(1)), and
45 should skip the full stop.  It is also conventional in most cases to
46 prefix the first line with "area: " where the area is a filename or
47 identifier for the general area of the code being modified, e.g.
49 * push: allow pushing to multiple remotes
51 * grep: allow passing in command-line arguments
53 If in doubt which identifier to use, run "git log --no-merges" on the
54 files you are modifying to see the current conventions.
56 The body should provide a meaningful commit message, which:
58 * explains the problem the change tries to solve, iow, what is wrong
59   with the current code without the change.
61 * justifies the way the change solves the problem, iow, why the
62   result with the change is better.
64 * alternate solutions considered but discarded, if any.
66 Describe your changes in imperative mood, e.g. "make xyzzy do frotz"
67 instead of "[This patch] makes xyzzy do frotz" or "[I] changed xyzzy
68 to do frotz", as if you are giving orders to the codebase to change
69 its behaviour.  Try to make sure your explanation can be understood
70 without external resources. Instead of giving a URL to a mailing list
71 archive, summarize the relevant points of the discussion.
73 If you like, you can put extra tags at the end:
75 * "Reported-by:" is used to credit someone who found the bug that
76   the patch attempts to fix.
78 * "Acked-by:" says that the person who is more familiar with the area
79   the patch attempts to modify liked the patch.
81 * "Reviewed-by:", unlike the other tags, can only be offered by the
82   reviewer and means that she is completely satisfied that the patch
83   is ready for application.  It is usually offered only after a
84   detailed review.
86 * "Tested-by:" is used to indicate that the person applied the patch
87   and found it to have the desired effect.
89 You can also create your own tag or use one that's in common usage
90 such as "Thanks-to:", "Based-on-patch-by:", or "Helped-by:".
92 ## Sign your work
94 To improve tracking of who did what, we've borrowed the
95 "sign-off" procedure from the Linux kernel project on patches
96 that are being emailed around.  Although core Git is a lot
97 smaller project it is a good discipline to follow it.
99 The sign-off is a simple line at the end of the explanation for
100 the patch, which certifies that you wrote it or otherwise have
101 the right to pass it on as an open-source patch.  The rules are
102 pretty simple: if you can certify the below:
104 Developer's Certificate of Origin 1.1
106 By making a contribution to this project, I certify that:
108 (a) The contribution was created in whole or in part by me and I
109     have the right to submit it under the open source license
110     indicated in the file; or
112 (b) The contribution is based upon previous work that, to the best
113     of my knowledge, is covered under an appropriate open source
114     license and I have the right under that license to submit that
115     work with modifications, whether created in whole or in part
116     by me, under the same open source license (unless I am
117     permitted to submit under a different license), as indicated
118     in the file; or
120 (c) The contribution was provided directly to me by some other
121     person who certified (a), (b) or (c) and I have not modified
122     it.
124 (d) I understand and agree that this project and the contribution
125 are public and that a record of the contribution (including all
126 personal information I submit with it, including my sign-off) is
127 maintained indefinitely and may be redistributed consistent with
128 this project or the open source license(s) involved.
130 then you just add a line saying
132 Signed-off-by: Random J Developer <random@developer.example.org>
134 This line can be automatically added by Git if you run the git-commit
135 command with the -s option, or using the `Ctrl+i` hotkey in git-cola's
136 commit message editor.
138 Notice that you can place your own Signed-off-by: line when
139 forwarding somebody else's patch with the above rules for
140 D-C-O.  Indeed you are encouraged to do so.  Do not forget to
141 place an in-body "From: " line at the beginning to properly attribute
142 the change to its true author (see (2) above).
144 Also notice that a real name is used in the Signed-off-by: line. Please
145 don't hide your real name.
147 ## Reporting Bugs
149 Please read [How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html)
150 for some general tips on bug reporting.
152 ## Internationalization and Localization
154 git-cola is translated to several languages.  When strings are presented to
155 the user they must use the `N_('<string>')` function so that `<string>` is
156 translated into a localized string.
158 The translation message files are the `*.po` files in the `cola/i18n/` directory.
159 Adding a new translation entails creating a new language-specific `.po` file.
161 When new (untranslated) strings are added to the project, the `git-cola.pot`
162 base template and the language-specific message files need to be updated with
163 the new strings.
165 To regenerate `git-cola.pot` and update `.po` files with new strings run:
167     make pot
169 This will update `.po` files with untranslated strings which translators can
170 use to translate `git-cola`.
172 Untranslated strings are denoted by an empty "" string.
174 Alternate translations can be tested by setting `$LANG` when running, e.g.
176     env LANG=zh_TW ./bin/git-cola
178 The [Gettext Language Code](https://www.gnu.org/software/gettext/manual/gettext.html#Language-Codes)
179 corresponds to the `.po` filename.  Country-specific suffixes use the
180 [Gettext country code](https://www.gnu.org/software/gettext/manual/gettext.html#Country-Codes).
182 We happily welcome pull requests with improvements to `git-cola`'s translations.
184 ## Fork the repo on Github and create a pull request.