Skip to content
Snippets Groups Projects
Commit 45f632c9 authored by ARUL DEVARAJAN's avatar ARUL DEVARAJAN Committed by Arul Kumaran
Browse files

Contribution Process.rst: Content updation for Contribution Workflow

* Signed-off by: Arul Kumaran <arulkumaran.devarajan@huawei.com>
parent e97b2d11
No related branches found
No related tags found
No related merge requests found
.. _Contributingcode:
.. include:: ../definitions.rst .. include:: ../definitions.rst
Contributing Code Contributing Code
......
...@@ -4,208 +4,156 @@ Contribution Process ...@@ -4,208 +4,156 @@ Contribution Process
#################### ####################
.. contents:: .. contents::
:depth: 1 :depth: 1
Preparations Contribution guidelines
************ ***********************
* Install, configure, and use Git. For details, visit https://docs.gitlab.com/runner/install/
* Register an SSH public key. For details, visit https://docs.gitlab.com/ee/ci/ssh_keys/README.html#how-it-works
* Find the repository that you are interested in on the code hosting platform of |main_project_name|.
Downloading Code
****************
Forking a Code Branch from the Cloud
====================================
#. Find and open the homepage of the repository.
#. Click the Fork button in the upper right corner, and create an individual cloud fork branch as prompted.
Downloading the Fork Repository to the Local Host
=================================================
Perform the following steps to download the code in the repository to your computer:
#. Create a local working directory.
A local working directory is used for searching and managing local code.
``mkdir ${your_working_dir}``
#. Clone the remote repository to the local host.
* Switch to the local path.
``mkdir -p ${your_working_dir}``
``cd ${your_working_dir}`` |main_project_name| is an open-source project where the community can submit merge requests directly to the project. This section explains how to report a new issue, requests for enhancements and submit merge request to the project in GitLab so that your patch is merged into the source code.
* Clone the remote repository. Changes must be committed with detailed Git commit messages. Each commit message must contain:
* You can copy the address of the remote repository on the repository page. * Short and descriptive subject line that is less than 72 characters, the subject line must include a prefix that identifies the subsystem being changed, followed by a colon, and a short title.
* Run the following command on the local host: * A change description with your logic or reasoning for the changes.
* A Signed-off-by line, Signed-off-by: <name> <email> typically added automatically by using git commit -s
* When editing the commit message, explain the changes and why the changes are required along with issue number.
* If the merge request addresses an issue, include a line of the form as below:
``git clone $remote_link`` .. code-block:: console
$ Fixes #<issue number>
Sign-off commit message
***********************
Committing Code Each commit message in Pull request must be signed-off with a proper format as follows:
***************
Committing a Repository (git clone) .. code-block:: console
===================================
$ Signed-off-by: OpenHarmony <sample@openharmonyproject.org>
#. Update the local branch. * Commit message text can be added either manually or include *-s* or *--signoff* to your GitLab commit message. For example:
``git fetch origin`` .. code-block:: console
$ Supported Boards Updation: Placeholder Updation
$ * Signed-off-by: OpenHarmony <sample@openharmonyproject.org>
``git checkout master`` * To amend and add sign-off message to the previous commit, run the following command:
``git pull --rebase`` .. code-block:: console
$ git commit --amend -s
Update the local debugging branch (myfeature branch) based on the remote master branch. * To force push your changes to GitLab commit message, run the following command:
``git branch myfeature origin/master`` .. code-block:: console
``git checkout myfeature`` $ git push -f
Then, edit and modify the code in the myfeature branch Prerequisites
*************
#. Commit the changes in the local working directory. * To configure, install and setup your development environment of |main_project_name|, see :ref:`Getting Started <BuildOpenharmony>`.
* Create a GitLab account on https://gitlab.com/users/sign_up and have Git tools available on your development system.
* Find the repository that you are interested in on the code hosting platform of |main_project_name|.
``git add .`` For downloading tools, downloading source code, and building and running |main_project_name| image, see :ref:`Getting Started <BuildOpenharmony>`.
``git commit -m "Reason"`` Coding guidelines
*****************
You may continue to edit and test more content after the previous commit. You can use commit --amend to commit these changes. Refer to the :ref:`Contributing Code <Contributingcode>` section of the documentation for additional details.
#. Push the changes to your remote directory. Contribution Workflow
*********************
If you plan to review (or just establish a remote backup of your work), push the branch to your fork repository: When contributing to the |main_project_name| Project, provide information about your change, update project documentation, and test your changes before you submit them.
``git push -f origin myfeature`` To simplify the review, merge and rebase, and to modify the commit history, perform the following contribution workflow process:
1. Click the Fork button in project repo page to create a Fork of |main_project_name| to your personal account on GitLab.
Committing Multiple Repositories (repo init/sync) 2. To work locally on an existing remote repository, clone the source files to your local computer through HTTPS or SSH, run:
=================================================
#. Configure the token of the global environment. .. code-block:: console
``repo config --global repo.token {TOKEN}`` $ git clone https://gitlab.com/<your-namespace>/sample-project.git
The token is generated by choosing **Settings > Security Settings > Private Token** on Gitlab. Example: 3. Navigate to the folder where source files were downloaded and add a remote repository:
``repo config --global repo.token 211XXXXXXXXXXXXXXXXXXXXXXXX`` .. code-block:: console
#. Create an issue under any repository to be modified on Gitlab, and record the issue number (for example, #I1TVV4 in the following figure). (The issue provides a function similar to changeID of Gerrit and is used to associate multiple repositories to be modified. Skip this step if modification of multiple repositories is not involved.) $ git remote add upstream git@gitlab.com:username/projectpath.git
#. Create a branch in the local code workspace, modify the code, and commit the changes. 4. Download the latest changes in the project, run:
``repo start branchname --all`` .. code-block:: console
After the code is modified, run the following command in multiple repositories: git pull <REMOTE> <name-of-branch>
``git add .`` 5. Run the following command to verify the remote repositories:
``git commit -m "xxxxxx"`` .. code-block:: console
$ git remote -v
Alternatively, use the repo tool to batch add or commit the changes in the root directory of the code project: The remote repositories are displayed as following:
``repo forall -c 'git add .'`` .. code-block:: console
$ origin https://gitlab.com/<your-namespace>/sample-project.git (fetch)
$ origin https://gitlab.com/<your-namespace>/sample-project.git (push)
$ upstream https://gitlab.com/gitlab-tests/sample-project.git. (fetch)
$ upstream https://gitlab.com/gitlab-tests/sample-project.git. (push)
``repo forall -c 'git commit -m "xxxxxx"'`` 6. Create a new branch based out of Master for making changes out of your local repository:
#. Push the code (repo upload is not supported). .. code-block:: console
Specify whether to directly generate a pull request (PR) during code push.
The value False indicates that a PR is not directly generated and needs to be manually generated in the fork warehouse. $ git checkout master
$ git checkout -b <branch_name>
The value True indicates that a PR is generated when the code is pushed to the fork repository. 7. Make the changes locally and once committed, add the files to the remote repository:
``repo config repo.pullrequest {True/False}`` .. code-block:: console
For example, if the PR is generated when the push code is selected, run the following command: $ git add [modified file]
``repo config repo.pullrequest True`` 8. Commit your changes to your local repo. Include *-s* to include **Signed-off-by:** to the commit message.
Run the following command to push the code: .. code-block:: console
``repo push --br={BRANCH} --d={DEST_BRANCH} --content={PR_CONTENT}`` $ git commit -s
**BRANCH** indicates the local branch, **DEST_BRANCH** indicates the destination branch (trunk branch), which is usually master, and PR_CONTENT indicates the PR description. If multi-repository committing is involved, the issue number must be entered. Example: 9. Push your new branch along with the changes to your fork in personal GitLab account:
``repo push --br="20200903" --d="master" --content="#I1TVV4"`` .. code-block:: console
On the editing page displayed, open the comment tags for the repository, branch, and commit. $ git push origin <branch_name>
Save the settings and exit. The repo tool automatically pushes the local branch to the remote fork repository (creates a fork repository if there is no fork repository) and generates a PR. 10. Merge a branch with master branch, run:
The tool automatically associates the PR with the issue. .. code-block:: console
Creating a Pull Request $ git checkout <branch_name>
*********************** $ git merge master
Access the fork repository on Gitlab, click the button for creating a PR, and select the myfeature branch to generate a PR. (Skip this step if a PR has been automatically created using the repo tool.)
For details, visit https://docs.gitlab.com/ee/ci/ci_cd_for_external_repos/#how-it-works All the local changes are merged into the master branch.
.. Note:: .. Note::
How do I create PRs at the same time if multiple code repositories have compilation dependencies? During the development of the operating system (OS), it is common that multiple code repositories have compilation dependencies. Therefore, the PRs need to be created and merged at the same time. For this reason, Gitlab uses issues as the dependency identifiers for code repositories with compilation dependencies to commit the PRs. For more details on using Git on the command line, see https://docs.gitlab.com/ee/gitlab-basics/start-using-git.html.
Follow the operations below:
#. Create an issue in any of the code repositories.
#. Associate PRs that need to be built and merged at the same time with the issue.
#. After the build is triggered, the build center identifies the PRs associated with the same issue, downloads the build,
and merges the PRs into the code library after the code is approved.
Building Access Control
***********************
Creating an Issue
=================
#. Go to the homepage of the repository.
#. Click the Issues tab in the upper left corner. Then, click the issue creation button on the right, and create a dedicated task as prompted to execute continuous integration (CI) access control for associated code (feature development/bug fixing).
Associating the Issue with the PR
=================================
When creating a PR or compiling an existing PR, enter #+I+five-digit issue ID in the description box to associate the issue with the PR.
Constraints
-----------
* One PR can be associated with only one issue. Otherwise, CI cannot be triggered.
* If feature development or bug fixing involves multiple code repositories, multiple PRs can be associated with the same issue.
* Among the PRs associated with the issue, no PR that has been merged or closed is allowed. Otherwise, the CI cannot be triggered.
* If an issue has been associated with a merged or closed PR, the issue cannot be reused. In this case, create another issue and associate
it with an open PR.
Triggering Code Access Control
==============================
Comment "start build" in the PR to trigger CI access control.
If multiple PRs are associated with the same issue, the comment "start build" on any PR can trigger the CI access control of the issue.
After the access control is executed, the execution result will be automatically commented in all the PRs associated with the issue.
If the access control is passed, all PRs associated with the issue will be automatically marked as "Passed".
Reviewing Code
==============
For details, visit https://docs.gitlab.com/ee/development/code_review.html#code-review-guidelines
Related topic: `FAQs <https://git.ostc-eu.org/docs/developer-guide/-/blob/master/documentation/source/readme/FAQs.rst>`_
Upstreaming Patches via e-mail
==============================
When upstreaming work we have done to a project which uses an e-mail based workflow there might be some pitfalls along the way.
Our attribution should be in place (namingly the use of the company e-mail address as git author and maybe the signed-off-by), but sending the patches via Outlook/Exchange is not possible as the server side is known to mangle the e-mail format and patches would no longer apply.
As a solution we recommend subscribing your private e-mail address to the mailing list and using it for sending the patches. We assume here that you have done the git commit with your correct company e-mail address and git send-email is already configured to send out e-mails ([sendemail] section of .gitconfig).
To keep the correct attribution in place we need to set set the --from field to our private e-mail when executing git send-email
``$ git send-email --from my.personal.email@gmail.com --to yocto@lists.yoctoproject.org my-patch-directory/*``
By doing this we can ensure that the original git author e-email address will be used when the patches are applied.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment