gitlab_delete_branch
Delete a branch from a GitLab project to manage repository structure and remove outdated code.
Instructions
Deletes a branch from a GitLab project.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectPath | Yes | The path of the GitLab project. | |
| branchName | Yes | The name of the branch to delete. |
Implementation Reference
- src/index.ts:1921-1935 (handler)Handler function for the 'gitlab_delete_branch' tool that extracts parameters and calls GitLabService.deleteBranch to perform the deletion.case 'gitlab_delete_branch': { if (!gitlabService) { throw new Error('GitLab service is not initialized.'); } const { projectPath, branchName } = args as { projectPath: string; branchName: string }; await gitlabService.deleteBranch(projectPath, branchName); return { content: [ { type: 'text', text: `Branch ${branchName} deleted successfully.`, }, ], }; }
- src/index.ts:791-808 (registration)Registers the 'gitlab_delete_branch' tool in the allTools array, including its name, description, and input schema.{ name: 'gitlab_delete_branch', description: 'Deletes a branch from a GitLab project.', inputSchema: { type: 'object', properties: { projectPath: { type: 'string', description: 'The path of the GitLab project.', }, branchName: { type: 'string', description: 'The name of the branch to delete.', }, }, required: ['projectPath', 'branchName'], }, },
- src/gitlab.service.ts:626-633 (helper)GitLabService method that performs the actual API call to delete the specified branch from the project.async deleteBranch(projectPath: string, branchName: string): Promise<void> { const encodedProjectPath = encodeURIComponent(projectPath); const encodedBranchName = encodeURIComponent(branchName); await this.callGitLabApi<any>( `projects/${encodedProjectPath}/repository/branches/${encodedBranchName}`, 'DELETE', ); }