Developing Code
CodeArts Repo offers Git-based online code management, including code cloning/commit and branch management.
This practice uses branches for code development. Branches let you develop features separately. They keep your work isolated from the main branch, ensuring it stays unaffected.
When a code repository is created, a default branch named master, that is, the main line, is generated. To ensure stable running of the Phoenix Mall, a stable and continuously available master branch is required. Instead of developing code on the master branch, developers are advised to use "function branches + merge requests". Each function branch must be reviewed by other members in the team before merge.
This section describes how to develop code for the store query function using branches.
Creating a Requirement Branch
Developer Chris creates a requirement branch in the repository to develop code for the new requirement.
- Go to the Phoenix Mall project, and choose Code > Repo from the navigation pane.
- Click the phoenix-sample repository.
- Choose Code > Branches and click Create Branch. In the displayed dialog box, set the following parameters and click OK.
Table 1 Creating a branch Parameter
Example
Description
Based On
master
Select an existing branch.
Branch Name
Feature-Store
Name of the branch you are creating. The name cannot exceed 200 bytes.
- Do not start with a hyphen (-), period (.), refs/heads/, or refs/remotes/.
- Do not use spaces or these special characters: [\<~^:?*!()'"|
- Do not end with a period (.), slash (/), or .lock.
CodeArts Req Work Items to Associate
Frontend display - Add store network menu
Associate an existing work item with the branch.
The Files page is displayed, showing the Feature-Store branch.
Figure 1 Feature-Store branch
Modifying and Committing Code
Developer Chris develops code in the requirement branch.
- In the Feature-Store branch of the phoenix-sample repository, find vote/templates/store-network.html and open it.
- Click
, add the following code to the file, enter the commit message "Store list added" in the text box at the bottom of the page, and click OK.
<ul> <li>Branch A: 123 meters to the departure floor, Terminal 1, Airport E</li> <li>Branch B: No. 456, Street G, Area F</li> <li>Branch C: No. 789, Street J, Area H</li> <li>Branch D: West side of Building K, Avenue L, Area K</li> </ul>
Figure 2 Committing codeThe modified code is displayed.
- Open and edit the /vote/templates/index.html file in the same way.
Add the following code to line 179, enter the commit message "fix #xxxxxx Frontend display - Add store network menu", and click OK. xxxxxx indicates the ID of the task Frontend display - Add store network menu.
<li class="nav-item"> <a href="store-network" class="nav-link">STORE NETWORK</a> </li>
The modified code is displayed.
- Viewing commit records
- Choose Work to enter the CodeArts Req service.
- On the Work Items tab, find the task Frontend display - Add store network menu. The task status has automatically updated to Resolved.
- Click the task title to open the details page.
- Click the Associations tab. Under Code Commits, a record is displayed, showing the commit message configured in 3.
Figure 3 Code commit records
Merging Code Through a Merge Request
After completing code development and self-testing, developer Chris submits a branch merge request. Project manager Maggie reviews the request and merges the branch.
- Chris submits a merge request.
- In the phoenix-sample code repository, click the Merge Requests tab, and click Create MR.
- Set the source branch to Feature-Store and the target branch to master, and click Next.
- Edit the merge request details by referring to the table below.
Table 2 Configuring a merge request Parameter
Example
Description
Source Branch
Feature-Store
The source branch of the merge request.
Target Branch
master
The target branch of the merge request.
Title
Add store list
The title of the merge request. Enter a maximum of 255 characters.
Mergers
Maggie
Members who will merge the code.
Approvers
Maggie
Members who will review the merge request.
- Click Create Merge Request to complete the creation.
The merge request details are displayed.
- Maggie reviews the merge request.
- Go to the phoenix-sample code repository, click the Merge Requests tab, and find the merge request created by developer Chris.
- Click the request to view details.
- Leave comments on the page. Click Approve in the Approval Gate area.
Figure 4 Approval gate
- Click Merge to merge the branch into master.
The code is merged.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot