跳转到内容
Try Gitea Cloud ☁️ for 30 days → Accelerate your Development & Deploys!
Support

Set the default commit message push rule owned by a repository

PUT
/repos/{owner}/{repo}/push_rules/default
curl --request PUT \
--url https://gitea.example.com/api/v1/repos/example/example/push_rules/default \
--header 'Authorization: Basic <credentials>' \
--header 'Content-Type: application/json' \
--data '{ "agent_branch_template": "example", "agent_exempt": [ "example" ], "author_email": "example", "branch_name": "example", "description": "example", "enabled": true, "example": "example", "forbidden": "example", "full_message": true, "max_commits": 1, "max_file_size_mb": 1, "mode": "inherit", "name": "example", "prohibited_file_names": "example", "required": "example", "version": 1 }'

Gitea Enterprise only. This endpoint is not part of the community edition.

owner
required
string

Owner of the repo

repo
required
string

Name of the repo

Media typeapplication/json
SetPushRuleOption sets the push rule owned by a scope.
object
agent_branch_template

Head branch name for new agent runs when the default name fails a branch name check; {agent} is replaced by the agent name and {issue} by the issue number or “work”

string
agent_exempt

Checks agents may skip: commit_message, branch_name, author_email, file_name, file_size. They cover branches an agent run creates and commits the agent authored, pushed by its run or merged from a pull request it opened

Array<string>
author_email

RE2 expression the author email of every new commit must match

string
branch_name

RE2 expression the name of a newly created branch must match; the default branch is always allowed

string
description
string
enabled
boolean
example
string
forbidden

RE2 expression the commit message must not match

string
full_message

Whether the expressions are matched against the full commit message instead of only its title

boolean
max_commits

Most new commits one push or merge may bring in while the commit checks run; 0 for no limit

integer format: int64
max_file_size_mb

Largest file in MiB a new commit may add or modify; 0 for no limit

integer format: int64
mode

Mode is only accepted for the default rule of an organization or a repository; the global scope and mandatory rules are always custom and ignore this field type: string inherit PushRuleModeInherit copy PushRuleModeCopy custom PushRuleModeCustom none PushRuleModeNone

string
Allowed values: inherit copy custom none
name
string
prohibited_file_names

RE2 expression no file path added or modified by a new commit may match

string
required

RE2 expression the commit message must match

string
version

Version of the rule loaded before editing; 0 when no rule exists

integer format: int64

PushRule

Media typeapplication/json

PushRule represents the push rule owned by a scope. A rule only ever describes what a scope owns itself; the effective rule enforced on a push is resolved separately, see EffectivePushRule.

object
agent_branch_template

Head branch name for new agent runs when the default name fails a branch name check; {agent} is replaced by the agent name and {issue} by the issue number or “work”

string
agent_exempt

Checks agents may skip: commit_message, branch_name, author_email, file_name, file_size. They cover branches an agent run creates and commits the agent authored, pushed by its run or merged from a pull request it opened

Array<string>
author_email

RE2 expression the author email of every new commit must match

string
branch_name

RE2 expression the name of a newly created branch must match; the default branch is always allowed

string
copied_at
string format: date-time
description
string
enabled
boolean
example
string
forbidden

RE2 expression the commit message must not match

string
full_message

Whether the expressions are matched against the full commit message instead of only its title

boolean
id
integer format: int64
kind

Type: string default PushRuleKindDefault mandatory PushRuleKindMandatory

string
Allowed values: default mandatory
max_commits

Most new commits one push or merge may bring in while the commit checks run; 0 for no limit

integer format: int64
max_file_size_mb

Largest file in MiB a new commit may add or modify; 0 for no limit

integer format: int64
mode

Mode is always custom for the global scope and for a mandatory rule; the default rule of an organization or a repository may also be inherit, copy or none type: string inherit PushRuleModeInherit copy PushRuleModeCopy custom PushRuleModeCustom none PushRuleModeNone

string
Allowed values: inherit copy custom none
name
string
prohibited_file_names

RE2 expression no file path added or modified by a new commit may match

string
required

RE2 expression the commit message must match

string
scope

Type: string global PushRuleScopeGlobal org PushRuleScopeOrg repo PushRuleScopeRepo

string
Allowed values: global org repo
scope_id

ID of the organization or repository that owns the rule; 0 for the global scope

integer format: int64
source

The scope the rule content was copied from, set only when mode is copy type: string global PushRuleScopeGlobal org PushRuleScopeOrg repo PushRuleScopeRepo

string
Allowed values: global org repo
source_id
integer format: int64
source_version
integer format: int64
updated_at
string format: date-time
version

Increments on every save of this rule

integer format: int64
Example
{
"kind": "default",
"mode": "inherit",
"scope": "global",
"source": "global"
}

APINotFound is a not found empty response

APIValidationError is error format response related to input validation

message
string
url
string

APIRepoArchivedError is an error that is raised when an archived repo should be modified

message
string
url
string