After almost an year receiving valuable code contribution from community through Gitlab, some difficulties were found by contributors when trying to organize their forked repositories and create a good merge request. This article presents a workflow to mitigate these common problems on contributor side.
These steps are recommended when contributing trough Gitlab:
The steps below use Git command line, but it can be performed in any Git client embedded in IDE. Also fabiomontefuscolo is the Gitlab user in this example and it should be replaced by Gitlab user who forked the repository.
$ git clone git@gitlab.com:fabiomontefuscolo/tiki.git tiki
For each major version of Tiki, there is a working branch. If the contribution is a fix for version 19.1 for example, the contributor must checkout the branch 19.x.
$ git checkout 19.x
This is a very important step. It is a good idea to create another branch for the contribution. According to earlier steps, the repository now is set to branch 19.x and a new branch will start from this point. Suppose branch with the name fixing-left-sidebar, the following command will create this branch.
$ git checkout -b fixing-left-sidebar
If for some reason the contributor needs to stop his work and start a new one for the same branch 19.x, he can simply commit or stash his changes, switch back to 19.x and create the new contribution he needs. For example, a new urgent task appeared to fix a security issue:
$ git checkout 19.x $ git checkout -b fixing-xss-issue-on-register-form
In this way, the contributor can have two ore more unrelated jobs (fixing-left-sidebar and fixing-xss-issue-on-register-form) for the same target branch (19.x). It will also help on Merge Request creation.
Even running on Gitlab, the community standards for commit messages should be respected. Remember to give a meaningful commit message and prefix it with a suitable tag explained in https://dev.tiki.org/Commit-Tags .
$ git add tiki-file.php $ git commit -m "[FIX] Removing bad characters from registration form to avoid XSS atacks"
In order to have changes available to create a new Merge Request, it is necessary to push the created branch to Gitlab.
$ git push -u origin fixing-xss-issue-on-register-form
Maintainers may ask you changes on that pull request. In this case, just checkout the branch related to the merge request, add new commits and push it again.
When commands like git reset --hard
or git push --force
is needed, it may be that there is a problem with the workflow and it should be planned again.