Updated on 2023-07-25 GMT+08:00

Repositories

To configure repository settings, you can choose Settings > Repository Management > Repository Settings on the repository details page.

The default branch is the branch selected by default when you enter the current repository and is also the default target branch when you create a merge request (MR). When a repository is created, the master branch is used as the default branch and can be manually adjusted at any time.

The settings take effect only for the repository configured.

Only the repository administrator and repository owner can view this page and have the setting permission. After the setting is complete, you can click Commits for the setting to take effect.

Table 1 Parameter description

Parameter

Description

Do not fork a repo.

This parameter is not selected by default. If this parameter is selected, all users cannot fork the repository.

Developers cannot create branches.

This parameter is not selected by default. If this parameter is selected, the developer role cannot create branches.

NOTE:

A whitelist can be set to prevent developers who are not in the whitelist from creating branches.

Developers cannot create tags.

This parameter is not selected by default. If this parameter is selected, the developer role cannot create tags.

Committers cannot create branches

This parameter is not selected by default. If this parameter is selected, the committer role cannot create branches.

Pre-merge

By default, this option is not selected. After this option is selected, the server automatically generates MR pre-merging code. Compared with running commands on the client, this operation is more efficient and simple, and the build result is more accurate. This option applies to scenarios that have strict requirements on real-time build.

Branch name rule

  • The value cannot exceed 200 bytes.
  • The name cannot start with -, refs/heads/, or refs/remotes/, and cannot contain spaces or special characters such as brackets ([), backward slashes (\), angle brackets (<), tildes (~), circumflexes (^), colons (:), question marks (?), asterisks (*), exclamation marks (!), parentheses (()) , single quotation marks ('), quotation marks ("), and vertical bars (|). It cannot end with ./ or .lock.
  • The name of a new branch cannot be the same as that of an existing branch or tag.

Tag name rule

  • The value cannot exceed 200 bytes.
  • The name cannot start with -, refs/heads/, or refs/remotes/, and cannot contain spaces or special characters such as brackets ([), backward slashes (\), angle brackets (<), tildes (~), circumflexes (^), colons (:), question marks (?), asterisks (*), exclamation marks (!), parentheses (()) , single quotation marks ('), quotation marks ("), and vertical bars (|). It cannot end with ./ or .lock.
  • The name of a new tag cannot be the same as that of an existing branch or tag.
  • Byte: a group of adjacent binary digits. It is an important data unit of computers and is usually represented by B. 1 B = 8 bits.
  • Character: a letter, digit, or another symbol that represents data and information.

Configuring MR Pre-combination

After an MR is created, you can customize the scripts for downloading plug-ins such as WebHook and CodeArts Pipeline. That is, you can control the downloaded code content.

  • If you select MR Pre-merge, the server will generate a hidden branch, indicating that the MR code has been merged. You can directly download the code that already exists in the hidden branch.
  • If MR Pre-merge is not selected, you need to perform pre-merge on the client. That is, download the code of the MR source branch and MR target branch and perform pre-merge on the build executor.

Command

The pre-merge command on the server is as follows:

git init  
git remote add origin ${repo_url clone/download address}
git fetch origin +refs/merge-requests/${repo_MR_iid}/merge:refs/${repo_MR_iid}merge

If this option is not selected, you can perform the pre-merge operation on the client and create a clean working directory on the local host. The command is as follows:

git init
git remote add origin ${repo_url clone/download address}
git fetch origin +refs/heads/${repoTargetBranch}:refs/remotes/origin/${repoTargetBranch}
git checkout ${repoTargetBranch}
git fetch origin +refs/merge-requests/${repo_MR_iid}/head:refs/remotes/origin/${repo_MR_iid}/head 
git merge refs/remotes/origin/${repo_MR_iid}/head --no-edit

Advantages

In scenarios that have high requirements on real-time build, for example, one MR may start the build of dozens or hundreds of servers, and the pre-merging result generated by the local or client may be inconsistent with that generated by the server. As a result, the build code cannot be obtained accurately and the build result is inaccurate. Pre-merging on the server can solve this problem in real time. In addition, the script building command is simpler, and developers or CIEs can better use it.