文档

CreateBranch - 创建分支

更新时间:

通过 OpenAPI 创建分支。

适用版本

企业专属版、企业标准版

服务接入点与授权信息

请求语法

POST https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/branches

请求头

参数

类型

是否必填

描述

示例值

x-yunxiao-token

string

个人访问令牌。

pt-0fh3****0fbG_35af****0484

请求参数

参数

类型

位置

是否必填

描述

示例值

organizationId

string

path

组织 ID。

99d1****71d4

repositoryId

string

path

代码库 ID 或者 URL-Encoder 编码的全路径。

2334815

branch

string

query

创建的分支名称。

createBranch

ref

string

query

来源分支名称。

master

请求示例

curl -X 'POST' \
  'https://test.rdc.aliyuncs.com/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/branches?branch=<branch>&ref=<ref>' \
  -H 'accept: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

返回参数

参数

类型

描述

示例值

-

object

commit

object

分支最近一次提交信息。

authorEmail

string

作者邮箱。

username@example.com

authorName

string

作者姓名。

阿里云云效

authoredDate

string

作者提交时间。

2022-03-18 09:00:00

committedDate

string

提交者提交时间。

2022-03-18 10:00:00

committerEmail

string

提交者邮箱。

username@example.com

committerName

string

提交者姓名。

阿里云云效committer

id

string

提交 ID。

ff4fb5ac6d1f44f452654336d2dba468ae6c8d04

message

string

提交内容。

create branch

parentIds

array[string]

父提交 ID。

shortId

string

代码组路径。

ff4fb5ac

stats

object

提交变更行统计。

additions

integer

增加行数。

5

deletions

integer

删除行数。

2

total

integer

总变动行数。

10

title

string

标题,提交的第一行内容。

创建代码库分支

webUrl

string

页面访问地址。

""

defaultBranch

boolean

是否是默认分支。

true

name

string

分支名称。

createBranch

protected

boolean

是否是保护分支。

false

webUrl

string

页面访问 URL。

""

返回示例

{
    "commit": {
        "authorEmail": "username@example.com",
        "authorName": "阿里云云效",
        "authoredDate": "2022-03-18 09:00:00",
        "committedDate": "2022-03-18 10:00:00",
        "committerEmail": "username@example.com",
        "committerName": "阿里云云效committer",
        "id": "ff4fb5ac6d1f44f452654336d2dba468ae6c8d04",
        "message": "create branch",
        "parentIds": [
            
        ],
        "shortId": "ff4fb5ac",
        "stats": {
            "additions": 5,
            "deletions": 2,
            "total": 10
        },
        "title": "创建代码库分支",
        "webUrl": "\"\""
    },
    "defaultBranch": false,
    "name": "createBranch",
    "protected": false,
    "webUrl": "\"\""
}

错误码

访问错误码中心查看 API 相关错误码。