get_branch
Retrieve branch details from Alibaba Cloud Codeup repositories to access commit history, permissions, and metadata for development workflows.
Instructions
[Code Management] Get information about a branch in 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 (if it contains special characters, use URL encoding), example: master or feature%2Fdev |
Implementation Reference
- tool-handlers/code-management.ts:26-36 (handler)Handler for the 'get_branch' tool. Parses input arguments and delegates to getBranchFunc to retrieve branch details.case "get_branch": { const args = types.GetBranchSchema.parse(request.params.arguments); const branch = await branches.getBranchFunc( args.organizationId, args.repositoryId, args.branchName ); return { content: [{ type: "text", text: JSON.stringify(branch, null, 2) }], }; }
- tool-registry/code-management.ts:13-16 (registration)Registration of the 'get_branch' tool, specifying name, description, and input schema.name: "get_branch", description: "[Code Management] Get information about a branch in a Codeup repository", inputSchema: zodToJsonSchema(types.GetBranchSchema), },
- operations/codeup/types.ts:226-230 (schema)Zod schema definition for 'get_branch' tool input validation.export const GetBranchSchema = 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 (if it contains special characters, use URL encoding), example: master or feature%2Fdev"), });
- operations/codeup/branches.ts:60-88 (helper)Core implementation function that handles URL encoding for repositoryId and branchName, makes GET request to Codeup API, and parses response with CodeupBranchSchema.export async function getBranchFunc( organizationId: string, repositoryId: string, branchName: string ): Promise<z.infer<typeof CodeupBranchSchema>>{ // 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: "GET", }); return CodeupBranchSchema.parse(response); }