Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Step 3: Writing Code

Updated on 2024-11-18 GMT+08:00

CodeArts Repo provides Git-based online code management service, including code cloning/commit and branch management.

This section uses store network query as an example to describe how to manage and develop source code. Store network query is a high-priority story.

In this sample project, code is developed in a branch. Developer Chris creates a branch in a code repository, develops code, and submits a merge request. Project manager Maggie approves the request and then merges it to the master branch.

Managing Code with a Branch

A branch is a tool for parallel feature development. Branches enable you to diverge from the main line of development and continue to do work without messing with that main line.

When a code repository is created, there is a default branch named master, that is, the main line. To ensure stable running of the Phoenix Mall, a stable and continuously available master is required. The project manager suggests "function branches + merge requests". Each function branch must be reviewed by other members in the team before merge.

  1. Set master as a protected branch (this operation is performed by project manager Maggie in this document).

    1. Go to the Phoenix Mall project, choose Code > Repo from the navigation pane, and locate the code repository phoenix-sample.
    2. Go to the code repository by clicking its name and click the Settings tab. Choose Policy Settings > Protected Branches from the navigation pane.
    3. Click Create Protected Branch. Complete the settings by referring to the following table and click OK.
      NOTE:

      If the protected branch master already exists on the page, click and modify the branch configuration as required.

      Table 1 Creating a protected branch

      Configuration Item

      Suggestion

      Branch

      Select master.

      Push

      Retain the default value.

      Merge

      Retain the default value.

      Members

      Retain the default value.

  2. Create a function branch (this operation is performed by developer Chris in this document).

    1. Go to the Phoenix Mall project. Choose Code > Repo. Find the phoenix-sample in the repository.
    2. Click the repository name to access the code repository. On the Code tab, click Branches.
    3. Click Create Branch, set the branch information by referring to Table 2, and click OK.
      Table 2 Creating a branch

      Configuration Item

      Suggestion

      Based On

      Select master.

      Branch

      Enter Feature-Store.

      Work Items to Associate

      Select User can query network of all stores.

Modifying and Committing Code

The store network query function is divided into frontend display and backend management tasks during sprint planning. This section uses task Frontend display - Add store network menu as an example to describe how to modify and commit code.

  1. Choose Work from the navigation pane, and click the Sprints tab.

    In sprint 4, find the task Frontend display - Add store network menu, and change the task status to Developing.

  2. Choose Code > Repo, and find the phoenix-sample repository.
  3. Go to the code repository by clicking its name and click the Code tab.
  4. Click master above the file list and select the branch Feature-Store from the drop-down list.
  5. Find vote/templates/store-network.html in the file list and open it.
  6. Click , add the store address specified in the story, 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>

  7. Open and edit the /vote/templates/index.html file in the same way.

    Add the menu Store Network in line 179, enter the commit message fix #xxxxxx Frontend display - Add store network menu, and click OK.

    In the preceding message, #xxxxxx indicates the ID of task Frontend display - Add store network menu, which is obtained from the work item list.
    <li class="nav-item"> <a href="store-network" class="nav-link">Store network</a> </li>

  8. Choose Work from the navigation pane, and click the Sprints tab.

    In sprint 4, find the task Frontend display - Add store network menu.
    • Click the task name. The task status automatically changes to Resolved on the details page.
    • Click the Associated tab. Under Code Commit Records, a record is displayed with the commit message configured in the previous step.
      Figure 1 Code commit records

Reviewing Code and Merging Branches

  1. The developer initiates a merge request.

    After coding, developer Chris initiates a merge request to merge their function branch into the master.

    1. Go to the code repository, click the Merge Requests tab, and click Create Merge Request.
    2. Set the source branch to Feature-Store and the target branch to master, and click Next.
    3. Edit the merge request details by referring to Table 3.
      Table 3 Merge request configurations

      Configuration Item

      Suggestion

      Title

      Enter Add store list.

      Mergers

      Click . In the dialog box that is displayed, select Maggie and click OK.

      Approvers

      Click . In the dialog box that is displayed, select Maggie and click OK.

    4. Click Create Merge Request to complete the creation.

  2. The project manager reviews the code and merges the commit request.

    In this document, project manager Maggie is both the approver and merger. Maggie approves the request content and merges the request.

    1. Go to the code repository, click the Merge Requests tab, and find the merge request created by developer Chris.
    2. Click the request to view details.
    3. Leave comments on the page. Click Approve in Approval Gate to complete the approval.
    4. Click Merge to merge the branch into master.
      NOTE:

      If you have selected Delete source branch after merged when creating a merge request, the branch Feature-Store will be deleted after the branch merge is complete.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback