Skip to content

Commit

Permalink
feat: POST /repos/{owner}/{repo}/branches/{branch}/rename (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
octokitbot committed Jan 22, 2021
1 parent 802c429 commit 5c30618
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 4 deletions.
66 changes: 64 additions & 2 deletions cache/openapi-schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"openapi": "3.0.3",
"info": {
"version": "2.4.2",
"version": "2.5.0",
"title": "GitHub's official OpenAPI spec + Octokit extension",
"description": "OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs",
"license": { "name": "MIT", "url": "https://spdx.org/licenses/MIT" },
Expand Down Expand Up @@ -16441,6 +16441,68 @@
"x-octokit": {}
}
},
"/repos/{owner}/{repo}/branches/{branch}/rename": {
"post": {
"summary": "Rename a branch",
"description": "Renames a branch in a repository.\n\n**Note:** Although the API responds immediately, the branch rename process might take some extra time to complete in the background. You won't be able to push to the old branch name while the rename process is in progress. For more information, see \"[Renaming a branch](https://docs.github.com/github/administering-a-repository/renaming-a-branch)\".\n\nThe permissions required to use this endpoint depends on whether you are renaming the default branch.\n\nTo rename a non-default branch:\n\n* Users must have push access.\n* GitHub Apps must have the `contents:write` repository permission.\n\nTo rename the default branch:\n\n* Users must have admin or owner permissions.\n* GitHub Apps must have the `administration:write` repository permission.",
"tags": ["repos"],
"operationId": "repos/rename-branch",
"externalDocs": {
"description": "API method documentation",
"url": "https://docs.github.com/rest/reference/repos#rename-a-branch"
},
"parameters": [
{ "$ref": "#/components/parameters/owner" },
{ "$ref": "#/components/parameters/repo" },
{ "$ref": "#/components/parameters/branch" }
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"new_name": {
"type": "string",
"description": "The new name of the branch."
}
},
"required": ["new_name"]
},
"example": { "new_name": "my_renamed_branch" }
}
}
},
"responses": {
"201": {
"description": "response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/branch-with-protection"
},
"examples": {
"default": {
"$ref": "#/components/examples/branch-with-protection"
}
}
}
}
},
"403": { "$ref": "#/components/responses/forbidden" },
"404": { "$ref": "#/components/responses/not_found" },
"422": { "$ref": "#/components/responses/validation_failed" }
},
"x-github": {
"githubCloudOnly": false,
"enabledForGitHubApps": true,
"previews": [],
"category": "repos",
"subcategory": "branches"
},
"x-octokit": {}
}
},
"/repos/{owner}/{repo}/check-runs": {
"post": {
"summary": "Create a check run",
Expand Down Expand Up @@ -67271,7 +67333,7 @@
},
"branch": {
"name": "branch",
"description": "branch+ parameter",
"description": "The name of the branch.",
"in": "path",
"required": true,
"schema": { "type": "string" },
Expand Down
50 changes: 49 additions & 1 deletion generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,9 @@ export interface paths {
put: operations["repos/set-user-access-restrictions"];
delete: operations["repos/remove-user-access-restrictions"];
};
"/repos/{owner}/{repo}/branches/{branch}/rename": {
post: operations["repos/rename-branch"];
};
"/repos/{owner}/{repo}/check-runs": {
post: operations["checks/create"];
};
Expand Down Expand Up @@ -10954,6 +10957,51 @@ export interface operations {
"422": unknown;
};
};
/**
* Renames a branch in a repository.
*
* **Note:** Although the API responds immediately, the branch rename process might take some extra time to complete in the background. You won't be able to push to the old branch name while the rename process is in progress. For more information, see "[Renaming a branch](https://docs.github.com/github/administering-a-repository/renaming-a-branch)".
*
* The permissions required to use this endpoint depends on whether you are renaming the default branch.
*
* To rename a non-default branch:
*
* * Users must have push access.
* * GitHub Apps must have the `contents:write` repository permission.
*
* To rename the default branch:
*
* * Users must have admin or owner permissions.
* * GitHub Apps must have the `administration:write` repository permission.
*/
"repos/rename-branch": {
parameters: {
path: {
owner: components["parameters"]["owner"];
repo: components["parameters"]["repo"];
branch: components["parameters"]["branch"];
};
};
requestBody: {
"application/json": {
/**
* The new name of the branch.
*/
new_name: string;
};
};
responses: {
/**
* response
*/
"201": {
"application/json": components["schemas"]["branch-with-protection"];
};
"403": unknown;
"404": unknown;
"422": unknown;
};
};
/**
* **Note:** The Checks API only looks for pushes in the repository where the check suite or check run were created. Pushes to a branch in a forked repository are not detected and return an empty `pull_requests` array.
*
Expand Down Expand Up @@ -22231,7 +22279,7 @@ export interface components {
*/
"workflow-id": number | string;
/**
* branch+ parameter
* The name of the branch.
*/
branch: string;
/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"branches": "main"
},
"octokit": {
"openapi-version": "2.4.2"
"openapi-version": "2.5.0"
},
"renovate": {
"extends": [
Expand Down

0 comments on commit 5c30618

Please sign in to comment.