feat(gitlab): add support for GitLab protected branches (list and unprotect)
This commit is contained in:
@@ -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.'
|
||||
}
|
||||
|
||||
@@ -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
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -4,6 +4,7 @@ export type {
|
||||
IGitLabProject,
|
||||
IGitLabGroup,
|
||||
IGitLabVariable,
|
||||
IGitLabProtectedBranch,
|
||||
IVariableOptions,
|
||||
IGitLabPipeline,
|
||||
IGitLabJob,
|
||||
|
||||
Reference in New Issue
Block a user