• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Contribution Process
2
3## Preparations
4
5-   Install, configure, and use Git. For details, visit  [https://gitee.com/help/categories/43](https://gitee.com/help/categories/43).
6-   Register an SSH public key. For details, visit  [https://gitee.com/help/articles/4191](https://gitee.com/help/articles/4191).
7-   Find the repository that you are interested in on the code hosting platform of OpenHarmony.
8
9## Downloading Code
10
11## Forking a Code Branch from the Cloud
12
131.  Find and open the homepage of the repository.
142.  Click the  **Fork**  button in the upper right corner, and create an individual cloud fork branch as prompted.
15
16## Downloading the Fork Repository to the Local Host
17
18Perform the following steps to download the code in the repository to your computer:
19
201.  Create a local working directory.
21
22    A local working directory is used for searching and managing local code.
23
24    ```
25    mkdir ${your_working_dir}
26    ```
27
282.  Clone the remote repository to the local host.
29    1.  Switch to the local path.
30
31        ```
32        mkdir -p ${your_working_dir}
33        cd ${your_working_dir}
34        ```
35
36    2.  Clone the remote repository.
37        - You can copy the address of the remote repository on the repository page.
38
39          **Figure  1** Cloning the remote repository
40
41          ![](figures/clone.png "clone")
42
43        -   Run the following command on the local host:
44
45            ```
46            git clone $remote_link
47            ```
48
49
50
51
52## Using the repo Tool to Download Code Repositories in Batches
53
541.  Download the repo tool. \(For details, see  [https://gitee.com/help/articles/4316](https://gitee.com/help/articles/4316).\)
55
56    ```
57    curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 > /usr/local/bin/repo
58    chmod a+x /usr/local/bin/repo
59    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests
60    ```
61
622.  Download code repositories. \(There is no  **repo branch**  parameter.\)
63
64    ```
65    repo init -u https://gitee.com/openharmony/manifest.git -b master
66    repo sync -c
67    ```
68
69
70## Committing Code
71
72## Committing a Repository \(git clone\)
73
741.  **Update the branch.**
75
76    Update your local branch.
77
78    ```
79    git remote add origin $remote_link
80    git fetch origin
81    git checkout master
82    git pull --rebase
83    ```
84
85    Update the local debugging branch \(**myfeature**  branch\) based on the remote  **master**  branch.
86
87    ```
88    git branch myfeature origin/master
89    git checkout myfeature
90    ```
91
92    Then, edit and modify the code in the  **myfeature**  branch.
93
942.  **Commit the changes in the local working directory.**
95
96    ```
97    git add .
98    git commit -sm "xxxxxx"  // Commit changes with a message containing the signoff email address.
99    ```
100
101    You may continue to edit and test more content after the previous commit. You can use  **commit --amend**  to commit these changes.
102
1033.  **Push the changes to your remote directory.**
104
105    If you plan to review \(or just establish a remote backup of your work\), push the branch to your fork repository:
106
107    ```
108    git push -f origin myfeature
109    ```
110
111
112## Committing Multiple Repositories \(repo init/sync\)
113
1141. Configure the token of the global environment.
115
116```
117repo config --global repo.token {TOKEN}
118```
119
120The token is generated by choosing  **Settings**  \>  **Security Settings**  \>  [**Private Token**](https://gitee.com/profile/personal_access_tokens)  on Gitee. Example:
121
122```
123repo config --global repo.token 211XXXXXXXXXXXXXXXXXXXXXXXX
124```
125
1262. Create an issue under any repository to be modified on Gitee, and record the issue number \(for example, \#I1TVV4 in the following figure\). \(The issue provides a function similar to change ID of Gerrit and is used to associate multiple repositories to be modified. Skip this step if modification of multiple repositories is not involved.\)
127
1283. Create a branch in the local code workspace, modify the code, and commit the changes.
129
130```
131repo start branchname --all
132```
133
134After the code is modified, run the following command in multiple repositories:
135
136```
137git add .
138git commit -sm "xxxxxx"
139```
140
141Alternatively, use the repo tool to batch add or commit the changes in the root directory of the code project:
142
143```
144repo forall -c 'git add .'
145repo forall -c 'git commit -sm "xxxxxx"'
146```
147
1484. Push the code. \(repo upload is not supported.\)
149
150Specify 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. The value  **True**  indicates that a PR is generated when the code is pushed to the fork repository.
151
152```
153repo config repo.pullrequest {True/False}
154```
155
156For example, if the PR is generated when the push code is selected, run the following command:
157
158```
159repo config repo.pullrequest True
160```
161
162Run the following command to push the code:
163
164```
165repo push --br={BRANCH} --d={DEST_BRANCH} --content={PR_CONTENT}
166```
167
168**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:
169
170```
171repo push --br="20200903" --d="master" --content="#I1TVV4"
172```
173
174On the editing page displayed, open the comment tags for the repository, branch, and commit.
175
176![](figures/figure2.png)
177
178Save 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.
179
180![](figures/figure3.png)
181
182The tool automatically associates the PR with the issue.
183
184## Creating a Pull Request
185
186Access the fork repository on Gitee, 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.\)
187
188For details, visit  [https://gitee.com/help/articles/4128](https://gitee.com/help/articles/4128).
189
190>![](public_sys-resources/icon-notice.gif) **NOTICE**
191>
192>**How do I create PRs at the same time if multiple code repositories have compilation dependencies?**
193>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, Gitee uses issues as the dependency identifiers for code repositories with compilation dependencies to commit the PRs. Follow the operations below:
194>
195>1.  Create an issue in any of the code repositories.
196>2.  Associate PRs that need to be built and merged at the same time with the issue. For details, visit  [https://gitee.com/help/articles/4142](https://gitee.com/help/articles/4142).
197>3.  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.
198
199## Building Access Control
200
201## Creating an Issue
202
2031.  Go to the homepage of the repository.
2042.  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\).
205
206## Associating the Issue with the PR
207
208When 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.
209
210**Constraints**
211
212-   One PR can be associated with only one issue. Otherwise, CI cannot be triggered.
213-   If feature development or bug fixing involves multiple code repositories, multiple PRs can be associated with the same issue.
214-   Among the PRs associated with the issue, no PR that has been merged or closed is allowed. Otherwise, the CI cannot be triggered.
215-   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.
216
217## Triggering Code Access Control
218
219Comment "start build" in the PR to trigger CI access control.
220
221If multiple PRs are associated with the same issue, the comment "start build" on any PR can trigger the CI access control of the issue.
222
223After the access control is executed, the execution result will be automatically commented in all the PRs associated with the issue.
224
225If the access control is passed, all PRs associated with the issue will be automatically marked as "Passed".
226
227## CI Portal
228
229The continuous integration (CI) portal is a platform where you can promptly view and analyze the execution results of code access control and daily build.
230
231On the CI portal, you can detect code bugs in a timely manner to ensure code reliability and function stability. The CI portal provides the following functions:
232
233- Code Access Control: After submitting a merge request to commit code, code access checks, such as the static code check, code build, and function test, are triggered. Code can be committed only after all checks are passed.
234
235
236- Daily Build: The continuous integration pipeline is automatically executed every day to detect issues with static code, code build, and functions in advance, thereby allowing you to resolve these issues in time to ensure high code quality.
237
238Visit [CI portal](http://ci.openharmony.cn/#/pipeLine).
239
240## Reviewing Code
241
242For details, visit [https://gitee.com/help/articles/4304](https://gitee.com/help/articles/4304).
243
244Related topic: [FAQs](FAQ.md)
245
246