Setting up Git
Gnome uses Git as a tool to make and manage all the changes of the code. So we have to learn some git. We will use mostly a tool called Gitg to manage our contributions.
The first thing you should do is configure git to know who you are:
Fixing the bug
A useful trick to help keep organized code is to assign a git branch for each bug you wish to fix that can be named bugXXXXXX where XXXXX is the number ID of the bug.
To create a new branch just click:
And switch your current code to that branch, clicking "checkout":
Now you can do the changes you want to do and build the application with Builder as we learnt at Newcomers/BuildGnome.
Is the bug fixed? Congratulations! You can go to the next step. If not, just do more changes and build and test until it is fixed.
Once you have made your changes, you need to create a commit. A commit means you make your changes permanent.
In Gitg simply click the "commit view" button:
And add the files that you changed from the "Unstaged" area to the "Staged" area:
And now you can do the actual commit, clicking the "Commit" button and it will show:
Now we can write our commit message following the guidelines. The commit message should follow a standard format: a short title of 50 chars length, followed by a longer explanation of 72 chars length each line, followed by a link to the relevant bug. Your commit message should look something like this:
modified-file: Short title describing your change Context of the bug/issue/change. The problem, when happens and why we need the change. Fix. Bugzilla link
Also important for your patches is to provide one patch per issue and not do unrelated modifications, for example, style changes.
To submit a patch, you have to select the commit you want to create a patch from and click "Create a patch":
Now attach the file to the bug report in Bugzilla and...
You submitted your first patch! Congratulations!
Follow up on the feedback
Your patch will likely go through several iterations of patch review. Wait to get comments about how you can improve the patch, and then make modifications if they are necessary. Then create a new patch and attach it to the bug. This kind of review process is standard practice within GNOME and helps to ensure that our code is all high-quality. Once your patch looks good, the reviewer will merge it in.
If your patch is accepted in the first review, you don't need to do this step, at least in this patch. Wait until the maintainer push your commit to the master branch.
If you need to modify your patch we need to reset the code changes to the previous commit, but with your changes in the stage area. To do so we need a terminal command (copy your commit message since it will be removed):
git reset --soft HEAD^
Now change the files you need and put them in the stage area as we learnt and commit again. Now you can attach the patch to Bugzilla again and repeat the process until your patch is accepted.