Skip to content

Commit 5c30618

Browse files
authored
feat: POST /repos/{owner}/{repo}/branches/{branch}/rename (#31)
1 parent 802c429 commit 5c30618

File tree

3 files changed

+114
-4
lines changed

3 files changed

+114
-4
lines changed

cache/openapi-schema.json

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"openapi": "3.0.3",
33
"info": {
4-
"version": "2.4.2",
4+
"version": "2.5.0",
55
"title": "GitHub's official OpenAPI spec + Octokit extension",
66
"description": "OpenAPI specs from https://github.com/github/rest-api-description with the 'x-octokit' extension required by the Octokit SDKs",
77
"license": { "name": "MIT", "url": "https://spdx.org/licenses/MIT" },
@@ -16441,6 +16441,68 @@
1644116441
"x-octokit": {}
1644216442
}
1644316443
},
16444+
"/repos/{owner}/{repo}/branches/{branch}/rename": {
16445+
"post": {
16446+
"summary": "Rename a branch",
16447+
"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.",
16448+
"tags": ["repos"],
16449+
"operationId": "repos/rename-branch",
16450+
"externalDocs": {
16451+
"description": "API method documentation",
16452+
"url": "https://docs.github.com/rest/reference/repos#rename-a-branch"
16453+
},
16454+
"parameters": [
16455+
{ "$ref": "#/components/parameters/owner" },
16456+
{ "$ref": "#/components/parameters/repo" },
16457+
{ "$ref": "#/components/parameters/branch" }
16458+
],
16459+
"requestBody": {
16460+
"content": {
16461+
"application/json": {
16462+
"schema": {
16463+
"type": "object",
16464+
"properties": {
16465+
"new_name": {
16466+
"type": "string",
16467+
"description": "The new name of the branch."
16468+
}
16469+
},
16470+
"required": ["new_name"]
16471+
},
16472+
"example": { "new_name": "my_renamed_branch" }
16473+
}
16474+
}
16475+
},
16476+
"responses": {
16477+
"201": {
16478+
"description": "response",
16479+
"content": {
16480+
"application/json": {
16481+
"schema": {
16482+
"$ref": "#/components/schemas/branch-with-protection"
16483+
},
16484+
"examples": {
16485+
"default": {
16486+
"$ref": "#/components/examples/branch-with-protection"
16487+
}
16488+
}
16489+
}
16490+
}
16491+
},
16492+
"403": { "$ref": "#/components/responses/forbidden" },
16493+
"404": { "$ref": "#/components/responses/not_found" },
16494+
"422": { "$ref": "#/components/responses/validation_failed" }
16495+
},
16496+
"x-github": {
16497+
"githubCloudOnly": false,
16498+
"enabledForGitHubApps": true,
16499+
"previews": [],
16500+
"category": "repos",
16501+
"subcategory": "branches"
16502+
},
16503+
"x-octokit": {}
16504+
}
16505+
},
1644416506
"/repos/{owner}/{repo}/check-runs": {
1644516507
"post": {
1644616508
"summary": "Create a check run",
@@ -67271,7 +67333,7 @@
6727167333
},
6727267334
"branch": {
6727367335
"name": "branch",
67274-
"description": "branch+ parameter",
67336+
"description": "The name of the branch.",
6727567337
"in": "path",
6727667338
"required": true,
6727767339
"schema": { "type": "string" },

generated/types.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,9 @@ export interface paths {
770770
put: operations["repos/set-user-access-restrictions"];
771771
delete: operations["repos/remove-user-access-restrictions"];
772772
};
773+
"/repos/{owner}/{repo}/branches/{branch}/rename": {
774+
post: operations["repos/rename-branch"];
775+
};
773776
"/repos/{owner}/{repo}/check-runs": {
774777
post: operations["checks/create"];
775778
};
@@ -10954,6 +10957,51 @@ export interface operations {
1095410957
"422": unknown;
1095510958
};
1095610959
};
10960+
/**
10961+
* Renames a branch in a repository.
10962+
*
10963+
* **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)".
10964+
*
10965+
* The permissions required to use this endpoint depends on whether you are renaming the default branch.
10966+
*
10967+
* To rename a non-default branch:
10968+
*
10969+
* * Users must have push access.
10970+
* * GitHub Apps must have the `contents:write` repository permission.
10971+
*
10972+
* To rename the default branch:
10973+
*
10974+
* * Users must have admin or owner permissions.
10975+
* * GitHub Apps must have the `administration:write` repository permission.
10976+
*/
10977+
"repos/rename-branch": {
10978+
parameters: {
10979+
path: {
10980+
owner: components["parameters"]["owner"];
10981+
repo: components["parameters"]["repo"];
10982+
branch: components["parameters"]["branch"];
10983+
};
10984+
};
10985+
requestBody: {
10986+
"application/json": {
10987+
/**
10988+
* The new name of the branch.
10989+
*/
10990+
new_name: string;
10991+
};
10992+
};
10993+
responses: {
10994+
/**
10995+
* response
10996+
*/
10997+
"201": {
10998+
"application/json": components["schemas"]["branch-with-protection"];
10999+
};
11000+
"403": unknown;
11001+
"404": unknown;
11002+
"422": unknown;
11003+
};
11004+
};
1095711005
/**
1095811006
* **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.
1095911007
*
@@ -22231,7 +22279,7 @@ export interface components {
2223122279
*/
2223222280
"workflow-id": number | string;
2223322281
/**
22234-
* branch+ parameter
22282+
* The name of the branch.
2223522283
*/
2223622284
branch: string;
2223722285
/**

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"branches": "main"
2424
},
2525
"octokit": {
26-
"openapi-version": "2.4.2"
26+
"openapi-version": "2.5.0"
2727
},
2828
"renovate": {
2929
"extends": [

0 commit comments

Comments
 (0)