Commit 7f181c21 authored by BO ZHANG's avatar BO ZHANG 🏀
Browse files

added merge_request.png

parent bbed3fa7
Loading
Loading
Loading
Loading
+75 −2
Original line number Diff line number Diff line
@@ -134,8 +134,8 @@ a code reviewer is required to merge approved code revisions into ``main`` branc
.. _csst-l1: https://csst-tb.bao.ac.cn/code/csst-l1


Code review
-----------
Code review mechanism
---------------------

Starting from C7, developers of all packages should NOT directly push any code
to *main* branch which is protected.
@@ -146,3 +146,76 @@ Developers should switch to a ``dev`` branch before doing anything.
Then commit code and push them to ``dev`` branch.


Workflow with ``dev`` branch
----------------------------

.. code-block::
    :caption: As a developer:

    (base) cham@MBP16 csst_proto % git branch -a # show all branch
      dev
    * main
      remotes/origin/main
    (base) cham@MBP16 csst_proto % git checkout dev # check out dev -> then you are in dev branch
    M       doc/source/conf.py
    M       doc/source/index.rst
    M       doc/source/integration.rst
    M       doc/source/vcs.rst
    Switched to branch 'dev'
    (base) cham@MBP16 csst_proto % git status # view code changes
    On branch dev
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git restore <file>..." to discard changes in working directory)
            modified:   doc/source/conf.py
            modified:   doc/source/index.rst
            modified:   doc/source/integration.rst
            modified:   doc/source/vcs.rst

    Untracked files:
      (use "git add <file>..." to include in what will be committed)
            doc/contents.md

    no changes added to commit (use "git add" and/or "git commit -a")
    (base) cham@MBP16 csst_proto % git add doc/source/*.rst doc/source/conf.py # add your code changes
    (base) cham@MBP16 csst_proto % git commit -m "updated doc: author info and docker info" # commit your changes
    [dev bbed3fa] updated doc: author info and docker info
     4 files changed, 73 insertions(+), 4 deletions(-)
    (base) cham@MBP16 csst_proto % git push origin dev # as a developer you are not allowed to push to main branch
    Enumerating objects: 15, done.
    Counting objects: 100% (15/15), done.
    Delta compression using up to 10 threads
    Compressing objects: 100% (8/8), done.
    Writing objects: 100% (8/8), 1.67 KiB | 1.67 MiB/s, done.
    Total 8 (delta 6), reused 0 (delta 0), pack-reused 0
    remote:
    remote: To create a merge request for dev, visit:
    remote:   http://10.3.10.28/code/csst-l1/csst_proto/-/merge_requests/new?merge_request%5Bsource_branch%5D=dev
    remote:
    To https://csst-tb.bao.ac.cn/code/csst-l1/csst_proto.git
     * [new branch]      dev -> dev

.. code-block::
    :caption: As a code reviewer:

    (base) cham@MBP16 csst_proto % git checkout main # check out main branch
    Switched to branch 'main'
    Your branch is up to date with 'origin/main'.
    (base) cham@MBP16 csst_proto % git merge dev # merge dev branch into main AFTER view changes
    Updating d9f64d3..bbed3fa
    Fast-forward
     doc/source/conf.py         |  2 +-
     doc/source/index.rst       | 11 +++++++++++
     doc/source/integration.rst | 50 +++++++++++++++++++++++++++++++++++++++++++++++---
     doc/source/vcs.rst         | 14 ++++++++++++++
     4 files changed, 73 insertions(+), 4 deletions(-)
    (base) cham@MBP16 csst_proto % git push origin main # push to remote main branch
    Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
    To https://csst-tb.bao.ac.cn/code/csst-l1/csst_proto.git
       d9f64d3..bbed3fa  main -> main

.. note::
    As a developer, you can also create a merge requrest to ask code reviewers to merge your changes on GitLab.
    Click ``Merge requests`` tag, click ``

.. image:: vcs/merge_request.png
+30.2 KiB
Loading image diff...