Imported Upstream version 2.74.4
[platform/upstream/glib.git] / CONTRIBUTING.md
1 # Contribution guidelines
2
3 Thank you for considering contributing to the GLib project!
4
5 These guidelines are meant for new contributors, regardless of their level
6 of proficiency; following them allows the core developers of the GLib project to
7 more effectively evaluate your contribution, and provide prompt feedback to
8 you. Additionally, by following these guidelines you clearly communicate
9 that you respect the time and effort that the people developing GLib put into
10 managing the project.
11
12 GLib is a complex free software utility library, and it would not exist without
13 contributions from the free and open source software community. There are
14 many things that we value:
15
16  - bug reporting and fixing
17  - documentation and examples
18  - tests
19  - testing and support for other platforms
20  - new features
21
22 Please, do not use the issue tracker for support questions. If you have
23 questions on how to use GLib effectively, you can use:
24
25  - the `#gtk` IRC channel on irc.gnome.org
26  - the [`glib` tag on GNOME's Discourse](https://discourse.gnome.org/tags/glib)
27
28 You can also look at the [`glib` tag on Stack
29 Overflow](https://stackoverflow.com/questions/tagged/glib).
30
31 The issue tracker is meant to be used for actionable issues only.
32
33 ## How to report bugs
34
35 ### Security issues
36
37 You should not open a new issue for security related questions.
38
39 When in doubt, send an email to the [security](mailto:security@gnome.org)
40 mailing list.
41
42 ### Bug reports
43
44 If you’re reporting a bug make sure to list:
45
46  0. which version of GLib are you using?
47  0. which operating system are you using?
48  0. the necessary steps to reproduce the issue
49  0. the expected outcome
50  0. a description of the behavior
51  0. a small, self-contained example exhibiting the behavior
52
53 If the issue includes a crash, you should also include:
54
55  0. the eventual warnings printed on the terminal
56  0. a backtrace, obtained with tools such as GDB or LLDB
57
58 If the issue includes a memory leak, you should also include:
59
60  0. a log of definite leaks from a tool such as [valgrind’s
61     memcheck](http://valgrind.org/docs/manual/mc-manual.html)
62
63 For small issues, such as:
64
65  - spelling/grammar fixes in the documentation,
66  - typo correction,
67  - comment clean ups,
68  - changes to metadata files (CI, `.gitignore`),
69  - build system changes, or
70  - source tree clean ups and reorganizations;
71
72 or for self-contained bug fixes where you have implemented and tested a solution
73 already, you should directly open a merge request instead of filing a new issue.
74
75 ### Features and enhancements
76
77 Feature discussion can be open ended and require high bandwidth channels; if
78 you are proposing a new feature on the issue tracker, make sure to make
79 an actionable proposal, and list:
80
81  0. what you’re trying to achieve and the problem it solves
82  0. three (or more) existing pieces of software which would benefit from the
83     new feature
84  0. how the feature is implementable on platforms other than Linux
85
86 New APIs, in particular, should follow the ‘rule of three’, where there should
87 be three (or more) pieces of software which are ready to use the new APIs. This
88 allows us to check that the new APIs are usable in real-life code, and fit well
89 with related APIs. This reduces the chances of awkward or unusable APIs becoming
90 stable in GLib and having to be supported forever.
91
92 A common way to introduce new APIs or data types to GLib is to prototype them in
93 another code base for a while, to gain real-life experience with them before
94 they are imported into GLib and marked as stable.
95
96 Each feature should also come fully documented, and with tests which approach
97 full branch coverage of the new code. GLib’s CI system generates code coverage
98 reports which are viewable for each merge request. See
99 [the testing policy](./docs/testing.md) for more details.
100
101 If proposing a large feature or change, it’s better to discuss it (on the
102 `#gtk` IRC channel or on [Discourse](https://discourse.gnome.org) before
103 putting time into writing an actionable issue — and certainly before putting
104 time into writing a merge request.
105
106 ## Your first contribution
107
108 ### Prerequisites
109
110 If you want to contribute to the GLib project, you will need to have the
111 development tools appropriate for your operating system, including:
112
113  - Python 3.x
114  - Meson
115  - Ninja
116  - Gettext (19.7 or newer)
117  - a [C99 compatible compiler](https://wiki.gnome.org/Projects/GLib/CompilerRequirements)
118
119 Up-to-date instructions about developing GNOME applications and libraries
120 can be found on [the GNOME Developer Center](https://developer.gnome.org).
121
122 The [GLib project uses GitLab](https://gitlab.gnome.org/GNOME/glib/) for code
123 hosting and for tracking issues. More information about using GitLab can be
124 found [on the GNOME wiki](https://wiki.gnome.org/GitLab).
125
126 ### Getting started
127
128 You should start by forking the GLib repository from the GitLab web UI, and
129 cloning from your fork:
130
131 ```sh
132 $ git clone https://gitlab.gnome.org/yourusername/glib.git
133 $ cd glib
134 ```
135
136 **Note**: if you plan to push changes to back to the main repository and
137 have a GNOME account, you can skip the fork, and use the following instead:
138
139 ```sh
140 $ git clone git@gitlab.gnome.org:GNOME/glib.git
141 $ cd glib
142 ```
143
144 To compile the Git version of GLib on your system, you will need to
145 configure your build using Meson:
146
147 ```sh
148 $ meson _builddir .
149 $ cd _builddir
150 $ ninja
151 ```
152
153 Typically, you should work on your own branch:
154
155 ```sh
156 $ git checkout -b your-branch
157 ```
158
159 Once you’ve finished working on the bug fix or feature, push the branch
160 to the Git repository and open a new merge request, to let the GLib
161 core developers review your contribution.
162
163 ### Code reviews
164
165 Each contribution is reviewed by the core developers of the GLib project.
166
167 The [CODEOWNERS](./docs/CODEOWNERS) document contains the list of core
168 contributors to GLib and the areas for which they are responsible; you
169 should ensure to receive their review and signoff on your changes.
170
171 It is our intention that every commit to GLib is reviewed by at least one other
172 person, including commits from core developers. We all make mistakes and can
173 always learn from each other, and code review allows that. It also reduces
174 [bus factor](https://en.wikipedia.org/wiki/Bus_factor) by spreading knowledge
175 of each commit between at least two people.
176
177 With each code review, we intend to:
178
179  0. Identify if this is a desirable change or new feature. Ideally for larger
180     features this will have been discussed (in an issue, on IRC, or on Discourse)
181     already, so that effort isn’t wasted on putting together merge requests
182     which will be rejected.
183  0. Check the design of any new API.
184  0. Provide realistic estimates of how long a review might take, if it can’t
185     happen immediately.
186  0. Ensure that all significant contributions of new code, or bug fixes, are
187     adequately tested, either through requiring tests to be submitted at the
188     same time, or as a follow-up.
189  0. Ensure that all new APIs are documented and have [introspection
190     annotations](https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations).
191  0. Check that the contribution is split into logically separate commits, each
192     with a good commit message.
193  0. Encourage further high quality contributions.
194  0. Ensure code style and quality is upheld.
195
196 If a code review is stalled (due to not receiving comments for two or more
197 weeks; or due to a technical disagreement), please ping another GLib core
198 developer on the merge request, or on IRC, to ask for a second opinion.
199
200 ### Commit messages
201
202 The expected format for git commit messages is as follows:
203
204 ```plain
205 Short explanation of the commit
206
207 Longer explanation explaining exactly what’s changed, whether any
208 external or private interfaces changed, what bugs were fixed (with bug
209 tracker reference if applicable) and so forth. Be concise but not too
210 brief.
211
212 Closes #1234
213 ```
214
215  - Always add a brief description of the commit to the _first_ line of
216  the commit and terminate by two newlines (it will work without the
217  second newline, but that is not nice for the interfaces).
218
219  - First line (the brief description) must only be one sentence and
220  should start with a capital letter unless it starts with a lowercase
221  symbol or identifier. Don’t use a trailing period either. Don’t exceed
222  72 characters.
223
224  - The main description (the body) is normal prose and should use normal
225  punctuation and capital letters where appropriate. Consider the commit
226  message as an email sent to the developers (or yourself, six months
227  down the line) detailing **why** you changed something. There’s no need
228  to specify the **how**: the changes can be inlined.
229
230  - When committing code on behalf of others use the `--author` option, e.g.
231  `git commit -a --author "Joe Coder <joe@coder.org>"` and `--signoff`.
232
233  - If your commit is addressing an issue, use the
234  [GitLab syntax](https://docs.gitlab.com/ce/user/project/issues/automatic_issue_closing.html)
235  to automatically close the issue when merging the commit with the upstream
236  repository:
237
238 ```plain
239 Closes #1234
240 Fixes #1234
241 Closes: https://gitlab.gnome.org/GNOME/glib/issues/1234
242 ```
243
244  - If you have a merge request with multiple commits and none of them
245  completely fixes an issue, you should add a reference to the issue in
246  the commit message, e.g. `Bug: #1234`, and use the automatic issue
247  closing syntax in the description of the merge request.
248
249 ### Merge access to the GLib repository
250
251 GLib is part of the GNOME infrastructure. At the current time, any
252 person with write access to the GNOME repository can merge merge requests to
253 GLib. This is a good thing, in that it allows maintainership to be delegated
254 and shared as needed. However, GLib is a fairly large and complicated package
255 that many other things depend on, and which has platform specific behavior — so
256 to avoid unnecessary breakage, and to take advantage of the knowledge about GLib
257 that has been built up over the years, we’d like to ask people contributing to
258 GLib to follow a few rules:
259
260 0. Never push to the `main` branch, or any stable branches, directly; you
261    should always go through a merge request, to ensure that the code is
262    tested on the CI infrastructure at the very least. A merge request is
263    also the proper place to get a comprehensive code review from the core
264    developers of GLib.
265
266 0. Always get a code review, even for seemingly trivial changes.
267
268 0. Pay attention to the CI results. Merge requests cannot be merged until the
269    CI passes. If they consistently fail, either something is wrong with the
270    change, or the CI tests need fixing — in either case, please bring this to
271    the attention of a core developer rather than overriding the CI.
272
273 If you have been contributing to GLib for a while and you don’t have commit
274 access to the repository, you may ask to obtain it following the [GNOME account
275 process](https://wiki.gnome.org/AccountsTeam/NewAccounts).