Open main menu

DAVE Developer's Wiki β

Changes

MISC-TN-028: GitLab-based workflow

1,020 bytes added, 09:04, 17 August 2023
Introduction
{| class="wikitable" border="1"
!Version
!Date
!Notes
|-
|1.0.0
|August 2023
|First public release
==Essential steps of the workflow==
We will show This section describes in detail the essential steps the workflow is composed of by using a very simple example. To this end, we created an will use a very simple example based on a ad hoc empty repository, named <code>test0</code>. The goal is to write the first release of the code by following the recommended workflow.
Once the repository is createdon GitLab, we create an issue. Every implementation should start with this step: '''first of all, create an issue'''!
In this case, we call the issue "First release" as shown by the following picture:
[[File:Gitlab-wf-1.png|center|thumb]]
Then, we create a merge request associated with the issue. We instruct GitLab to automatically create a branch associated with this issue as well. The branch will be called <code>1-first-release</code> and its source branch is <code>mainmaster</code>. This means then when the merge request is accepted, the new code in the branch <code>1-first-release</code> will be merged into the branch <code>mainmaster</code>.
[[File:Gitlab-wf-2.png|center|thumb]]
Please note that the merge options are so that the branch will be deleted when the merge request is accepted. This usually makes sense because we don't need to keep the branch we when the job is done. If you are askingto yourself, don't worry: although the branch will be is deleted, commits will not be lost. Therefore, the history of changes will be preserved.
[[File:Gitlab-wf-3.png|center|thumb]]
On GitLab side everything is in place, so we can work on our local host to write our code. For the sake of simplicity, we will just edit one file, <code>README.md</code>.
Of course, the first step consists of cloning the repository:
</pre>
TheaThen, we checkout the branch named <code>1-first-release</code>:
<pre class="workstation-terminal">
$ cd test0/
/test0$ git branch -a
* master
remotes/origin/1-first-release
remotes/origin/HEAD -> origin/master
remotes/origin/master
/test0$ git checkout 1-first-release
Branch '1-first-release' set up to track remote branch '1-first-release' from 'origin'.
Switched to a new branch '1-first-release'
/test0$ ll
total 12
drwxrwxr-x 3 llandre llandre 4096 ago 16 22:06 ./
</pre>
We edit the <code>README.md </code> file with our favorite editor, then we commit our changes and push them to the remote repository:
<pre class="workstation-terminal">
/test0$ git diff
diff --git a/README.md b/README.md
index e69de29..901353b 100644
@@ -0,0 +1 @@
+This is the first release.
/test0$ git add README.md /test0$ git commit -m "Change README.md"
[1-first-release ce31afa] Change README.md
1 file changed, 1 insertion(+)
/test0$ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
</pre>
We can now move back to GitLab[[File:Gitlab-side and close the merge requestwf-4.png|center|thumb]]
[[File:Gitlab-wfOn GitLab-4side we can close the merge request.png|center|thumb]]We mark it as ready in order to prepare it for merging:[[File:Gitlab-wf-5.png|center|thumb]]In case you have the permission to start the merging by yourself, you can press the "Merge" button. If you do not have such permission, for example because you have been assigned a <code>developer</code> role, this operation will be run by the <code>maintainer</code> of the repository.[[File:Gitlab-wf-6.png|center|thumb]]After merging is complete, you should see something like this:[[File:Gitlab-wf-7.png|center|thumb]]If we check the <code>master</code> branch, GitLab confirms that the merging was completed successfully:[[File:Gitlab-wf-8.png|center|thumb]]We can also see a graphical representation of we just did where it is clear the that temporary branch was deleted after having been merged into the <code>master</code> branch: [[File:Gitlab-wf-9.png|center|thumb]] == Conclusion ==We strongly recommend to use this workflow for any implementation, being it adding a new feature, fixing a bug, optimizing a function, or whatever. Even though it may seem a little bit cumbersome at first sight, it has proved to be very efficient and effective when several developers
4,650
edits