跳转到内容
EN

Create a project's default branch

Code Mode: praxis.devops.projects.defaultBranch.initialize

HTTP: POST /devops/v1/projects/{id}/default-branch:initialize

Create the default branch of a project on our own Git, once. A git package imported from elsewhere can hold branches and no default branch, and every change is cut from the default branch, so until it exists no change can be opened. The default branch is protected and only DevOps holds the credential that may write it, so this call is the one way to create it: it points the default branch at the head of the existing branch named in from (for example import). It only creates: a default branch that already exists is refused with DEFAULT_BRANCH_EXISTS and is never moved, a from that is not a branch of the repository is REF_NOT_FOUND, and a GitHub project is INVALID_ARGUMENT because GitHub’s branches are GitHub’s. The push reaches the project like any other push to its default branch. Read the project first (devops.projects.retrieve) for the package’s default branch name.

签名

praxis.devops.projects.defaultBranch.initialize(args:{path:{/** e.g. "dvp_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id:string};body:{/** An existing branch of the repository, for example import. e.g. "import" */ from:string}}):Promise<{/** The default branch the project declares, now created. e.g. "main" */ defaultBranch:string;/** The branch it was started from. e.g. "import" */ from:string;/** The commit the default branch points at, the head of from when it was read. e.g. "4f2a9c1d8e7b6a5c4d3e2f1a0b9c8d7e6f5a4b3c" */ commit:string}>;

参数

名称位置类型必填说明
idpathstring是The project identifier returned by the project list, not the project’s display name or its repository name.

请求体

必填内容类型说明
是application/jsonThe existing branch to start the default branch from.

响应

状态码内容类型说明
200application/jsonThe default branch now exists: its name, the branch it was started from and the commit it points at.
400application/jsonINVALID_PARAMS or INVALID_ARGUMENT means a field, query value or identifier violates the documented format or range — an unknown enum value, a pageSize outside 1..100, an unsupported filter or orderBy field, or an id with the wrong prefix. Correct the named input; nothing was read or written.
401application/jsonThe API key is missing or invalid; send a valid Praxis API key in the Authorization header before retrying.
403application/jsonThe credential carries no organization, or that organization cannot reach this project; use a key belonging to the project’s organization. No cross-organization read is possible.
404application/jsonPROJECT_NOT_FOUND means no project with that id is visible to this organization; list the projects and use an id from that answer.
409application/jsonDEFAULT_BRANCH_EXISTS means the default branch is already there; it is never moved by this call.
500application/jsonINTERNAL means the service could not complete the request; retry once, and if it repeats report the request id. A read is safe to repeat; a write that failed this way should be re-read before it is sent again.