delete_branch
Remove branches from Codeup repositories to maintain clean codebases and manage development workflows in Alibaba Cloud DevOps.
Instructions
[Code Management] Delete a branch from a Codeup repository
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| organizationId | Yes | Organization ID, can be found in the basic information page of the organization admin console | |
| repositoryId | Yes | Repository ID or a combination of organization ID and repository name, for example: 2835387 or organizationId%2Frepo-name (Note: slashes need to be URL encoded as %2F) | |
| branchName | Yes | Branch name (use URL-Encoder for encoding, example: feature%2Fdev) |
Implementation Reference
- tool-handlers/code-management.ts:38-48 (handler)Handler case for the delete_branch tool. Parses input arguments using DeleteBranchSchema and delegates to branches.deleteBranchFunc, returning the result as JSON text.case "delete_branch": { const args = types.DeleteBranchSchema.parse(request.params.arguments); const result = await branches.deleteBranchFunc( args.organizationId, args.repositoryId, args.branchName ); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- operations/codeup/types.ts:232-236 (schema)Zod schema defining the input parameters for the delete_branch tool: organizationId, repositoryId, and branchName.export const DeleteBranchSchema = z.object({ organizationId: z.string().describe("Organization ID, can be found in the basic information page of the organization admin console"), repositoryId: z.string().describe("Repository ID or a combination of organization ID and repository name, for example: 2835387 or organizationId%2Frepo-name (Note: slashes need to be URL encoded as %2F)"), branchName: z.string().describe("Branch name (use URL-Encoder for encoding, example: feature%2Fdev)"), });
- tool-registry/code-management.ts:18-21 (registration)Tool registration entry for delete_branch, including name, description, and input schema reference.name: "delete_branch", description: "[Code Management] Delete a branch from a Codeup repository", inputSchema: zodToJsonSchema(types.DeleteBranchSchema), },
- operations/codeup/branches.ts:96-127 (helper)Core implementation function deleteBranchFunc that constructs the API URL (handling URL encoding for repositoryId and branchName) and makes a DELETE request to the Codeup API to delete the branch.export async function deleteBranchFunc( organizationId: string, repositoryId: string, branchName: string ): Promise<DeleteBranchResponse> { // Automatically handle unencoded slashes in repositoryId if (repositoryId.includes("/")) { // Found unencoded slash, automatically URL encode it const parts = repositoryId.split("/", 2); if (parts.length === 2) { const encodedRepoName = encodeURIComponent(parts[1]); // Remove + signs from encoding (spaces are encoded as +, but we need %20) const formattedEncodedName = encodedRepoName.replace(/\+/g, "%20"); repositoryId = `${parts[0]}%2F${formattedEncodedName}`; } } // Automatically handle unencoded slashes in branchName if (branchName.includes("/")) { branchName = encodeURIComponent(branchName); } const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${repositoryId}/branches/${branchName}`; const response = await yunxiaoRequest(url, { method: "DELETE", }); return { branchName: branchName }; }