feat(gitlab): add support for GitLab protected branches (list and unprotect)

This commit is contained in:
2026-02-28 16:59:43 +00:00
parent 016eaf1b91
commit 82940c7c0f
5 changed files with 36 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import type {
IGitLabGroup,
IGitLabVariable,
IVariableOptions,
IGitLabProtectedBranch,
IGitLabPipeline,
IGitLabJob,
ITestConnectionResult,
@@ -369,6 +370,24 @@ export class GitLabClient {
);
}
// ---------------------------------------------------------------------------
// Protected Branches
// ---------------------------------------------------------------------------
public async getProtectedBranches(projectId: number | string): Promise<IGitLabProtectedBranch[]> {
return this.request<IGitLabProtectedBranch[]>(
'GET',
`/api/v4/projects/${encodeURIComponent(projectId)}/protected_branches`,
);
}
public async unprotectBranch(projectId: number | string, branchName: string): Promise<void> {
await this.request(
'DELETE',
`/api/v4/projects/${encodeURIComponent(projectId)}/protected_branches/${encodeURIComponent(branchName)}`,
);
}
// ---------------------------------------------------------------------------
// Project Deletion
// ---------------------------------------------------------------------------