import type { BaseResponse } from '@/types/base';
import type { ExternalSystemResponse } from '@/pages/Deploy/External/types';

// Git仓库组
export interface RepositoryGroup {
    id: number;
    groupId: number;
    name: string;
    path: string;
    description: string;
    visibility: string;
    parentId: number | null;
    webUrl: string;
    avatarUrl: string;
}

// Git项目
export interface RepositoryProject {
    id: number;
    projectId: number;
    name: string;
    path: string;
    description: string;
    visibility: string;
    groupId: number;
    isDefaultBranch: string;
    webUrl: string;
    sshUrl: string;
    httpUrl: string;
    lastActivityAt: string;
}

// Git实例信息
export interface GitInstanceInfo {
    totalGroups: number;
    lastSyncGroupsTime: string;
    totalProjects: number;
    lastSyncProjectsTime: string;
    totalBranches: number;
    lastSyncBranchesTime: string;
    repositoryGroupList: RepositoryGroup[];
    repositoryProjectList: RepositoryProject[];
}

// 使用外部系统响应作为 Git 实例
export type GitInstance = ExternalSystemResponse;

// Git 仓库详情
export interface GitRepositoryDTO extends BaseResponse {
    repoName: string;
    repoUrl: string;
    description: string;
    defaultBranch: string;
    visibility: 'public' | 'private';
    lastCommitTime?: string;
    lastCommitMessage?: string;
    lastCommitAuthor?: string;
    totalBranches: number;
    totalTags: number;
    totalCommits: number;
    externalSystemId: number;
}

// Git 分支信息
export interface GitBranchDTO extends BaseResponse {
    branchName: string;
    isDefault: boolean;
    isProtected: boolean;
    lastCommitSha: string;
    lastCommitMessage: string;
    lastCommitAuthor: string;
    lastCommitTime: string;
    repositoryId: number;
}

// Git 标签信息
export interface GitTagDTO extends BaseResponse {
    tagName: string;
    tagMessage: string;
    taggerName: string;
    taggerEmail: string;
    taggedTime: string;
    commitSha: string;
    repositoryId: number;
}

// 同步类型
export type SyncType = 'repositories' | 'branches' | 'tags';
