Updated on 2024-12-12 GMT+08:00

Configuring Code Commit Rules

Configuring Repo-Level Commit Rules

CodeArts Repo allows you to create verification and restriction rules for code commits to ensure code quality. You can select Inherit from project to automatically inherit and use the project settings. The settings cannot be modified.

You can also access the CodeArts Repo homepage. Choose Settings > Policy Settings > Commit rules, and click Create Commit Rule. For details about the parameters, see Table 1

Table 1 Parameters on the Commit Rules page

Parameter

Description

Reject non-signed-off-by commits

Only signed-off-by commits are pushed to the repository.

CodeArts Repo signature mode:

When performing online commit in CodeArts Repo, use the following format to compile and submit information:

commit message             # Enter the customized submission information.
                           # This is a blank line.
Signed-off-by: User-defined signature   # Enter the user-defined signature after Signed-off-by:

Git client signature mode:

When running the commit command on the Git client, you need to add the -s parameter.

git commit -s -m "<your commit message>"

You need to configure the signature and email address on the client in advance.

Reject commits not signed by GPG

Only GPG-signed commits are pushed to the repository.

Configure a GPG key:

git config --global user.signingkey "your GPG private key"

Git client signature mode:

When running the commit command on the Git client, you need to add the -S parameter.

git commit -S -m "Your commit message"

When running the tag command on the Git client, you need to add the -s parameter.

git tag -s -m "Your tag message"

You need to configure the signature and email address on the client in advance.

Tags cannot be deleted

After this option is selected, tags cannot be deleted on the page or by running commands on the client.

Prevent committing secrets

Example: id_rsa and id_dsa files.

Prevent git push -f

Indicates whether users can run the git push -f command on the client to push code.

git push -f indicates that the current local code repository is pushed to and overwrites the code in CodeArts Repo.

In general cases, you are not advised using this command.