2 Commits

Author SHA1 Message Date
e94004742f v2.3.0 2026-02-28 16:59:43 +00:00
82940c7c0f feat(gitlab): add support for GitLab protected branches (list and unprotect) 2026-02-28 16:59:43 +00:00
6 changed files with 37 additions and 2 deletions

View File

@@ -1,5 +1,14 @@
# Changelog
## 2026-02-28 - 2.3.0 - feat(gitlab)
add support for GitLab protected branches (list and unprotect)
- Added IGitLabProtectedBranch interface
- Added GitLabClient.getProtectedBranches(projectId) returning IGitLabProtectedBranch[]
- Added GitLabClient.unprotectBranch(projectId, branchName) to remove branch protection
- Exported IGitLabProtectedBranch from index.ts
- Non-breaking API additions; recommended minor version bump
## 2026-02-28 - 2.2.0 - feat(gitlabclient)
add deleteProject method to delete a project using GitLab API DELETE /api/v4/projects/:id

View File

@@ -1,6 +1,6 @@
{
"name": "@apiclient.xyz/gitlab",
"version": "2.2.0",
"version": "2.3.0",
"private": false,
"description": "A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.",
"main": "dist_ts/index.js",

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@apiclient.xyz/gitlab',
version: '2.2.0',
version: '2.3.0',
description: 'A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.'
}

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
// ---------------------------------------------------------------------------

View File

@@ -44,6 +44,12 @@ export interface IVariableOptions {
environment_scope?: string;
}
export interface IGitLabProtectedBranch {
id: number;
name: string;
allow_force_push: boolean;
}
export interface IGitLabPipeline {
id: number;
project_id: number;

View File

@@ -4,6 +4,7 @@ export type {
IGitLabProject,
IGitLabGroup,
IGitLabVariable,
IGitLabProtectedBranch,
IVariableOptions,
IGitLabPipeline,
IGitLabJob,