contribute: Document backport workflow for GStreamer developers
[platform/upstream/gstreamer.git] / markdown / contribute / index.md
1 ---
2 short-description: Contributing to GStreamer
3 ...
4
5 # How to Contribute to GStreamer
6
7 This document provides instructions and guidelines for submitting issues,
8 feature requests and patches to GStreamer. The following applies to all
9 these operations:
10
11 - Please use [Freedesktop.org Gitlab][gitlab] to perform any of the aforementioned
12   operations. You will need to create a Freedekstop.org Gitlab account if you
13   don't have one yet (yep, that's just how it is. Sorry for the inconvenience).
14
15 ## How to File Issues and Request for Enhancements
16
17 ### Where to File Issues and Feature Requests
18
19 - Create a new issue if there is no report for this problem yet.
20   The GStreamer [bugs page][bugs] also has shortcuts for the major components
21   and simple search functionality if you'd like to browse or search for
22   existing issues.
23
24 - If you are filing a feature request (i.e. anything that is not supposed to
25   work already, that is anything not an issue), please add the *Enhancement* label.
26   Feel free to add any other appropriate already existing labels.  Please don't
27   create new labels just for your issue. This won't affect the way we prioritise
28   the issue, but it will make triaging easier for us.
29
30 - If your issue is about a specific plugin, element or utility library,
31   please prefix the issue summary with `element-name:`, `plugin-name:` or `lib:`
32   and keep the rest of the description as short and precise as possible.
33
34   Examples:
35
36    - `id3demux: fails to extract composer tags`
37    - `tsdemux: does not detect audio stream`
38    - `Internal flow error when playing matroska file`
39
40   This makes sure developers looking through the list of open issues or issue
41   notification mails can quickly identify what your issue is about. If your text
42   is too long and only contains fill words at the beginning, the important
43   information will be cut off and not show up in the list view or mail client.
44
45 - If you don't know in which component the problem is, just select "don't know"
46   and we'll move it to the right component once we have a better idea what the
47   problem is.
48
49 - Please mention:
50
51    - what version of GStreamer you are using
52    - what operating system you are using (Windows, macOS, Linux)
53    - if you're on Linux, please mention your distro and distro version
54    - if this is on an embedded device please provide details
55
56 - Try to describe how the issue can be reproduced. If it is triggered by any
57   specific file, try to make the file available somewhere for download and
58   put the link into the issue. The easier it is for us to reproduce
59   the issue, the easier it is to fix it.
60
61 - If you experience a crash (that is: the application shuts down unexpectedly,
62   usually with a segfault or bus error or memory access violation or such),
63   please try to [obtain a stack trace][stack-trace]. If there are criticals
64   or warnings printed right before the crash, run with the environment variable
65   `G_DEBUG=fatal_warnings` set, then it will abort on the first warning, which
66   should hopefully give an indication to where the problem is. You can then
67   obtain a stack trace from where it aborts.
68
69 - If the application errors out, please provide a gst debug log. You can get
70   one by setting the `GST_DEBUG=*:6` environment variable, combined with
71   `GST_DEBUG_FILE=/tmp/dbg.log`. The resulting file might end up being very
72   large, so it's advisable to compress it with `xz -9 /tmp/dbg.log` before
73   sharing. You may also be asked to provide debug logs for specific debug
74   categories rather than everything (`*:6`).
75
76 [stack-trace]: https://wiki.gnome.org/Community/GettingInTouch/Bugzilla/GettingTraces/Details
77
78 ## How to Submit Patches
79
80 ### Where to Submit Patches
81
82 After completing the common steps:
83
84 - Once you have created an issue you can submit a merge request, see below for
85   more details.
86
87 - If your change is for an enhancement (anything that is not supposed to work
88   already, i.e. anything not a bug) or adds new API, please add the
89   *Enhancement* label. This won't affect the way we prioritise your issue,
90   but it does make triaging easier for us.
91
92 - If your merge request is against a specific plugin or element or utility library,
93   please prefix the merge request summary with `element-name:`, `plugin-name:`
94   or `lib:` and keep the rest of the description as short and precise as possible.
95
96   Examples:
97
98    - `id3demux: add support for WCOP frame`
99    - `riff: add RGB16 support`
100    - `playbin: detect if video-sink supports deinterlacing`
101    - `tests: rtprtx unit test is racy`
102
103   This makes sure developers looking through the list of open merge requests or
104   notification mails can quickly identify what your change is about. If your text
105   is too long and only contains fill words at the beginning, the important
106   information will be cut off and not show up in the list view or mail client.
107
108 - Please enable the "Allow commits from members who can merge to the target branch"
109   checkbox when submitting merge requests as otherwise maintainers might
110   request you to rebase your Merge Request multiple times even if no manual
111   changes are required.
112
113 - Make liberal use of the reference syntax available to help cross-linking
114   different issues and merge requests. e.g. `#100` references issue 100 in the
115   current module. `!100` references merge request 100 in the current project.
116   A complete list is available from [gitlab's documentation][special-md-references].
117
118 - Please create separate merge requests for separate issues and for different
119   modules. There is no golden rule when something counts as a separate issue,
120   please just use your best judgment.  If a merge request is related to another
121   merge request in another module please mention that in the description using
122   a gitlab reference as outlined above.  For example, if you have a change that
123   needs to be done in each module, one issue with one merge request per module
124   is fine. If there is an issue that requires related fixes in multiple elements
125   or libraries, please also feel free to put everything into one issue. If you
126   just happen to have multiple patches for us but they are not really related,
127   please put them in separate issues and merge requests. The main question is
128   if it makes sense to discuss and review these patches together or if they
129   could just as well be handled completely separately.
130
131 - Please do not send patches to the gstreamer-devel mailing list. Patches
132   submitted on the mailing list are most likely going to be ignored, overlooked,
133   or you will get a brief reply asking you to put them into gitlab. We do
134   not use the mailing list for patch review.
135
136 - Please do not send pull requests to our github mirror. They will be closed
137   automatically.
138
139 - Please do not attach patches to existing bugs on [GNOME Bugzilla][bugzilla]
140   If you want to reopen an already closed bug, let one of the developers know
141   and we will look into that on a case-by-case basis.
142
143 - Please do not attach patches to issues.
144
145
146 [special-md-references]: https://docs.gitlab.com/ee/user/markdown.html#special-gitlab-references
147 [bugzilla]: https://bugzilla.gnome.org/
148 [bugs]: https://gstreamer.freedesktop.org/bugs/
149 [gitlab]: https://gitlab.freedesktop.org/gstreamer
150
151 ### How to Prepare a Merge Request for Submission
152
153 If possible at all, you should prepare a merge request against a current git
154 checkout, ideally against the tip of the master branch.  The gitlab mrege request
155 UI will contain information about whether the merge request can be applied to the
156 current code. If a merge request was prepared against an old commit and
157 does not apply any longer to master you may be asked to provide an updated
158 branch to merge.
159
160 If you have created a new plugin, please submit a merge request that adds it to
161 the gst-plugins-bad module, including `configure.ac`, the various `Makefile.am`
162 modifications, `meson.build` modifications, and all new files.
163
164 #### Patch Format
165
166 The easiest way to create a merge request is to create one or more local commits
167 for your changes in a branch in a local git repository. This should be a git
168 clone checkout of your fork of the module in question.  To fork a module go to
169 the module in question (e.g.
170 [https://gitlab.freedesktop.org/gstreamer/gstreamer](https://gitlab.freedesktop.org/gstreamer/gstreamer))
171 and hit the fork button.  A new repository will be created in your user namespace
172 and should accessible as
173 [https://gitlab.freedesktop.org/$USERNAME/gstreamer](https://gitlab.freedesktop.org/$USERNAME/gstreamer).
174 You should clone this repository with valid ssh credentials to be able to
175 automatically push code to your fork.
176
177 Once you have a git repository with the original code in it, you should create a
178 branch for your change. e.g. to create a branch and checkout:
179
180     git checkout -b topic-branch
181
182 Then you can make your modifications and create a local commit with e.g.
183
184     git commit path/to/file1.[ch]
185
186 This will pop up an editor where you can create your commit message. It should
187 look something like:
188
189     exampledemux: fix seeking without index in push mode
190
191     Without an index we would refuse to seek in push mode. Make
192     seeking without an index work by estimating the position
193     to seek to. It might not be 100% accurate, but better than
194     nothing.
195
196     https://bugzilla.gnome.org/show_bug.cgi?id=987654
197
198 Then exit the editor, and you should have a commit.
199
200 It's best to run `git add` or `git commit` on specific directories or files
201 instead of using `git commit -a`, as it's too easy to accidentally contaminate
202 a patch with changes that belong into it with `git commit -a`, in particular
203 changes to the `common` submodule.
204
205 You can check your commit(s) with `git show` or `git log -p` or using a GUI
206 such as `gitg` or `gitk`.
207
208 Make sure the author is correctly set to your full name and e-mail address.
209
210 If you haven't used git before, it would be a good idea to tell it who you are:
211
212     $ git config --global user.name "George S. Treamer"
213     $ git config --global user.email "george.s.treamer@example.com"
214
215 You can make changes to the last commit using:
216
217  - `git commit --amend` to fix up the commit message
218
219  - `git commit --amend --author='John You <john@you.com>'` to fix up the author
220
221  - `git add path/to/file1.[ch]; git commit --amend` to incorporate fixes
222     made to the files since the last commit (i.e. what shows up in `git diff`).
223     If you just want to add some of the changes, but not all of them you can
224     use `git add -p file.c`, then it will ask you for each individual change
225     whether you want to add it or leave it.
226
227 Once everything looks fine, push your branch to your local fork e.g. using
228
229     git push origin topic-branch
230
231 This push will display a link to be able create a merge request from your branch.
232 Click this link and fill out the details of the merge request.  You can also
233 create a merge request from an existing branch. See the
234 [gitlab documentation][create-mr] for more details.
235
236 Please make sure your commits are as terse and precise as possible. Do not
237 include 'clean-ups' or non-functional changes, since they distract from the
238 real changes and make things harder to review, and also lower the chances that
239 the patch will still apply cleanly to the latest version in git. If you feel
240 there are things to clean up, please submit the clean-ups as a separate patch
241 that does not contain any functional changes.
242
243 Try to stick to the GStreamer indentation and coding style. There is a script
244 called [`gst-indent`][gst-indent] which you can run over your `.c` or `.cpp`
245 files if you want your code auto-indented before making the patch. The script
246 requires GNU indent to be installed already. Please do _not_ run `gst-indent` on
247 header files, our header file indentation is free-form. If you build GStreamer
248 from git, a local commit hook will be installed that checks if your commit
249 conforms to the required style (also using GNU indent).
250
251 [gst-indent]: https://gitlab.freedesktop.org/gstreamer/gstreamer/tree/master/tools/gst-indent
252 [create-mr]: https://docs.gitlab.com/ee/gitlab-basics/add-merge-request.html
253
254 ### Writing Good Commit Messages
255
256 Please take the time to write good and concise commit messages.
257
258 The first line of each commit message should be a short and concise summary
259 of the commit. If the commit applies to a specific subsystem, library, plugin
260 or element, prefix the message with the name of the component, for example:
261
262     oggdemux: fix granulepos query for the old theora bitstream
263
264 or
265
266     docs: add new stream API
267
268 or
269
270     tests: video: add unit test for converting RGB to XYZ colorspace
271
272 This should be a *summary* of the change and _not a description_ of the change.
273 Meaning: don't say *how* you did something but *what* you fixed, improved or
274 changed, what the most important practical *effect* of the change is. Example:
275
276     qtdemux: fix crash when doing reverse playback in push mode (good)
277
278 instead of
279
280     qtdemux: use signed integer to avoid counter underrun (bad)
281
282 The second line of the commit message should be empty.
283
284 The third and following lines should contain an extensive *description* and
285 *rationale* of the change made: what was changed, what was broken, how did it
286 get fixed, what bugs or issues does this fix? And most importantly: *why* was
287 something changed.
288
289 Trivial commits do not require a description, e.g. if you fix a memory leak
290 it's usually enough to just say that you fixed a leak. Maybe mention what was
291 leaked and perhaps also if it was an important leak or only happens in some
292 corner case error code path, but in any case there's no need to write a long
293 explanation why leaks are bad or why this needed fixing.
294
295 The important part is really what the reasoning behind the change is, since
296 that's what people want to know if they try to figure out twelve months later
297 why a line of code does what it does.
298
299 If the commit is related to any particular issues in gitlab, please add the
300 full issue URL at the end of the commit message.
301
302     https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/123
303
304 We do not use `Signed-off by:` lines in GStreamer, please create commits
305 without those.
306
307 ### After Submitting your Patch
308
309 Whenever you submit a new merge request, add a comment to an existing issue or
310 merge request, Gitlab will send a notification e-mail to GStreamer
311 developers. This means that there is usually no need to advertise the fact that
312 you have done so in other forums such as on IRC or on the mailing list, unless
313 you have been asked to file an issue there, in which case it's nice to follow up
314 with the link to the issue.
315
316 Most of all, please be patient.
317
318 We try to review patches as quickly as possible, but there is such a high
319 turnaround of issues, merge requests and feature requests that it is not always
320 possible to tend to them all as quickly as we'd like. This is especially
321 true for completely new plugins or new features.
322
323 If you haven't received any response at all for a while (say two weeks or so),
324 do feel free to ping developers by posting a quick follow-up comment on the
325 issue or merge request.
326
327 If you do not get a response, this is usually not a sign of people *ignoring*
328 the issue, but usually just means that it's fallen through the cracks or
329 people have been busy with other things.
330
331 # Workflows for GStreamer developers
332
333 ## Backporting to a stable branch
334
335 Before backporting any changes to a stable branch, they should first be
336 applied to the `master` branch, and should obviously not have caused any known
337 outstanding regressions. The only exception here are changes that do not apply
338 to the `master` branch anymore.
339
340 Existing merge request against the `master` branch, including merged ones,
341 that should be considered for backporting in the future should be labeled with
342 the `Needs backport` label unless there is any specific urgency to get it
343 backported. All merge requests with the (`Needs backport`)[needs-backport]
344 label will be regularly considered for backporting by GStreamer developers.
345
346 ### Creating a merge request for backports
347
348 When creating a merge request for backporting changes, include one or more
349 changes in the merge request and ideally all from the (list)[needs-backport]
350 after reviewing them and potentially fixing them to work cleanly with the
351 stable branch.
352
353 If there are specific commits or areas of commits where further feedback is
354 needed, please create a task list in the description of the merge request and
355 @ the committer or whoever has knowledge about this commit.
356
357 Add another task to the task list in the merge request's description for the
358 module's maintainer(s) to confirm the merge and @ one or more maintainers.
359
360 Only once the CI succeeded for the merge request and all tasks are solved,
361 especially the confirmation from the maintainer(s), the merge request can be
362 merged.
363
364 [needs-backport]: https://gitlab.freedesktop.org/groups/gstreamer/-/merge_requests?state=merged&label_name[]=Needs%20backport