git-aiflow
Version:
🚀 An AI-powered workflow automation tool for effortless Git-based development, combining smart GitLab/GitHub merge & pull request creation with Conan package management.
138 lines • 4.85 kB
TypeScript
import { GitService } from './git-service.js';
import { HttpClient } from '../http/http-client.js';
import { LoadedConfig } from '../config.js';
/**
* Git platform merge/pull request response
*/
export interface MergeRequestResponse {
web_url: string;
id: number;
title: string;
number?: number;
}
/**
* Git platform project information
*/
export interface GitPlatformProject {
id: string;
name: string;
full_name: string;
web_url: string;
}
/**
* Merge Request configuration options
*/
export interface MergeRequestOptions {
assignee_id?: number;
assignee_ids?: number[];
reviewer_ids?: number[];
squash?: boolean;
removeSourceBranch?: boolean;
description?: string;
}
/**
* Abstract base class for Git platform services
*/
export declare abstract class GitPlatformService {
protected readonly token: string;
protected readonly baseUrl: string;
protected readonly http: HttpClient;
protected readonly gitService: GitService;
protected constructor(token: string, baseUrl: string, gitService: GitService, http: HttpClient);
/**
* Get the platform name (e.g., 'gitlab', 'github')
*/
abstract getPlatformName(): string;
/**
* Get project information by path
* @param projectPath Project path (e.g., 'user/repo')
* @returns Project information
*/
abstract getProjectByPath(projectPath: string): Promise<GitPlatformProject>;
/**
* Get project information from current Git remote
* @returns Project information
*/
getProject(): Promise<GitPlatformProject>;
/**
* Create a merge/pull request (internal implementation)
* @param sourceBranch Source branch name
* @param targetBranch Target branch name
* @param title Request title
* @param options Merge request options including assignees, reviewers, squash, etc.
* @returns Raw platform response
*/
protected abstract createMergeRequestInternal(sourceBranch: string, targetBranch: string, title: string, options?: MergeRequestOptions): Promise<MergeRequestResponse>;
/**
* Create a merge/pull request
* @param sourceBranch Source branch name
* @param targetBranch Target branch name
* @param title Request title
* @param options Merge request options including assignees, reviewers, squash, etc.
* @returns Web URL of the created request
*/
createMergeRequest(sourceBranch: string, targetBranch: string, title: string, options?: MergeRequestOptions): Promise<string>;
/**
* Create a merge/pull request (legacy method for backward compatibility)
* @param sourceBranch Source branch name
* @param targetBranch Target branch name
* @param title Request title
* @param squash Whether to squash commits
* @param removeSourceBranch Whether to remove source branch after merge
* @returns Web URL of the created request
* @deprecated Use createMergeRequest with options parameter instead
*/
createMergeRequestLegacy(sourceBranch: string, targetBranch: string, title: string, squash?: boolean, removeSourceBranch?: boolean): Promise<string>;
/**
* Get the base URL of this service
*/
getBaseUrl(): string;
}
/**
* Supported Git platforms
*/
export declare enum GitPlatform {
GITLAB = "gitlab",
GITHUB = "github",
GITEE = "gitee",
GITEE_ORG = "gitee_org",
CODING = "coding",
CODING_ORG = "coding_org"
}
/**
* Get Git access token for current repository
* @param config Loaded configuration
* @param gitService GitService instance
* @returns Access token for the current Git remote hostname
*/
export declare function getGitAccessTokenForCurrentRepo(config: LoadedConfig, gitService: GitService): string;
/**
* Factory for creating Git platform services
*/
export declare class GitPlatformServiceFactory {
private static readonly logger;
/**
* Create a Git platform service with full automatic detection and configuration
* Automatically loads configuration, detects Git remote, and creates appropriate platform service
* @returns Platform service or undefined if not supported
*/
static create(): Promise<GitPlatformService | undefined>;
/**
* Detect Git platform from hostname
* @param hostname Git hostname
* @param gitService GitService instance for API detection
* @returns Detected platform or undefined
*/
private static detectPlatform;
/**
* Detect platform by probing API endpoints
* @param baseUrl Base URL of the Git hosting service
* @returns Detected platform or undefined
*/
private static detectPlatformByApi;
/**
* Get list of supported platforms
*/
static getSupportedPlatforms(): GitPlatform[];
}
//# sourceMappingURL=git-platform-service.d.ts.map