feat(gitlab): add repository branches and tags endpoints and corresponding types
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-03-02 - 2.4.0 - feat(gitlab)
|
||||||
|
add repository branches and tags endpoints and corresponding types
|
||||||
|
|
||||||
|
- Add getRepoBranches(projectId, opts?) to list repository branches (supports pagination with page and perPage; defaults to page=1, perPage=50).
|
||||||
|
- Add getRepoTags(projectId, opts?) to list repository tags (supports pagination with page and perPage; defaults to page=1, perPage=50).
|
||||||
|
- Introduce IGitLabBranch and IGitLabTag interfaces and export them from ts/index.ts.
|
||||||
|
|
||||||
## 2026-02-28 - 2.3.0 - feat(gitlab)
|
## 2026-02-28 - 2.3.0 - feat(gitlab)
|
||||||
add support for GitLab protected branches (list and unprotect)
|
add support for GitLab protected branches (list and unprotect)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@apiclient.xyz/gitlab',
|
name: '@apiclient.xyz/gitlab',
|
||||||
version: '2.3.0',
|
version: '2.4.0',
|
||||||
description: 'A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.'
|
description: 'A TypeScript client for the GitLab API, providing easy access to projects, groups, CI/CD variables, and pipelines.'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import type {
|
|||||||
IGitLabVariable,
|
IGitLabVariable,
|
||||||
IVariableOptions,
|
IVariableOptions,
|
||||||
IGitLabProtectedBranch,
|
IGitLabProtectedBranch,
|
||||||
|
IGitLabBranch,
|
||||||
|
IGitLabTag,
|
||||||
IGitLabPipeline,
|
IGitLabPipeline,
|
||||||
IGitLabJob,
|
IGitLabJob,
|
||||||
ITestConnectionResult,
|
ITestConnectionResult,
|
||||||
@@ -370,6 +372,28 @@ export class GitLabClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Repository Branches & Tags
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public async getRepoBranches(projectId: number | string, opts?: IListOptions): Promise<IGitLabBranch[]> {
|
||||||
|
const page = opts?.page || 1;
|
||||||
|
const perPage = opts?.perPage || 50;
|
||||||
|
return this.request<IGitLabBranch[]>(
|
||||||
|
'GET',
|
||||||
|
`/api/v4/projects/${encodeURIComponent(projectId)}/repository/branches?page=${page}&per_page=${perPage}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async getRepoTags(projectId: number | string, opts?: IListOptions): Promise<IGitLabTag[]> {
|
||||||
|
const page = opts?.page || 1;
|
||||||
|
const perPage = opts?.perPage || 50;
|
||||||
|
return this.request<IGitLabTag[]>(
|
||||||
|
'GET',
|
||||||
|
`/api/v4/projects/${encodeURIComponent(projectId)}/repository/tags?page=${page}&per_page=${perPage}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Protected Branches
|
// Protected Branches
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -70,6 +70,20 @@ export interface IGitLabJob {
|
|||||||
duration: number;
|
duration: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IGitLabBranch {
|
||||||
|
name: string;
|
||||||
|
commit: {
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IGitLabTag {
|
||||||
|
name: string;
|
||||||
|
commit: {
|
||||||
|
id: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export interface ITestConnectionResult {
|
export interface ITestConnectionResult {
|
||||||
ok: boolean;
|
ok: boolean;
|
||||||
error?: string;
|
error?: string;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ export type {
|
|||||||
IGitLabGroup,
|
IGitLabGroup,
|
||||||
IGitLabVariable,
|
IGitLabVariable,
|
||||||
IGitLabProtectedBranch,
|
IGitLabProtectedBranch,
|
||||||
|
IGitLabBranch,
|
||||||
|
IGitLabTag,
|
||||||
IVariableOptions,
|
IVariableOptions,
|
||||||
IGitLabPipeline,
|
IGitLabPipeline,
|
||||||
IGitLabJob,
|
IGitLabJob,
|
||||||
|
|||||||
Reference in New Issue
Block a user