大声道撒旦
This commit is contained in:
parent
465d71d74e
commit
20df7a8488
@ -53,7 +53,10 @@ public class RepositoryBranch extends Entity<Long> {
|
|||||||
private String webUrl;
|
private String webUrl;
|
||||||
|
|
||||||
@Column(name = "project_id", nullable = false)
|
@Column(name = "project_id", nullable = false)
|
||||||
private Long projectId;
|
private Long projectId; // 我们数据库的project表的ID
|
||||||
|
|
||||||
|
@Column(name = "git_project_id", nullable = false)
|
||||||
|
private Long gitProjectId; // GitLab的真实project_id
|
||||||
|
|
||||||
@Column(name = "external_system_id", nullable = false)
|
@Column(name = "external_system_id", nullable = false)
|
||||||
private Long externalSystemId;
|
private Long externalSystemId;
|
||||||
|
|||||||
@ -129,9 +129,10 @@ public class RepositoryBranchServiceImpl extends BaseServiceImpl<RepositoryBranc
|
|||||||
for (RepositoryProject project : projects) {
|
for (RepositoryProject project : projects) {
|
||||||
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
CompletableFuture<Void> future = CompletableFuture.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
log.info("Syncing branches for project: {} (ID: {})", project.getName(), project.getProjectId());
|
log.info("Syncing branches for project: {} (ID: {}, GitLab ID: {})",
|
||||||
|
project.getName(), project.getId(), project.getProjectId());
|
||||||
|
|
||||||
// 4.1 获取当前项目在GitLab上的所有分支
|
// 4.1 获取当前项目在GitLab上的所有分支,使用GitLab的真实project_id
|
||||||
List<GitBranchResponse> remoteBranches = gitServiceIntegration.branches(externalSystem, project.getProjectId());
|
List<GitBranchResponse> remoteBranches = gitServiceIntegration.branches(externalSystem, project.getProjectId());
|
||||||
log.info("Found {} remote branches for project: {}", remoteBranches.size(), project.getName());
|
log.info("Found {} remote branches for project: {}", remoteBranches.size(), project.getName());
|
||||||
|
|
||||||
@ -167,7 +168,8 @@ public class RepositoryBranchServiceImpl extends BaseServiceImpl<RepositoryBranc
|
|||||||
|
|
||||||
log.info("Completed processing {} branches for project: {}", remoteBranches.size(), project.getName());
|
log.info("Completed processing {} branches for project: {}", remoteBranches.size(), project.getName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to sync branches for project: {} (ID: {})", project.getName(), project.getProjectId(), e);
|
log.error("Failed to sync branches for project: {} (ID: {}, GitLab ID: {})",
|
||||||
|
project.getName(), project.getId(), project.getProjectId(), e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}, executor);
|
}, executor);
|
||||||
@ -211,9 +213,14 @@ public class RepositoryBranchServiceImpl extends BaseServiceImpl<RepositoryBranc
|
|||||||
|
|
||||||
RepositoryBranch branch = existingBranchMap.getOrDefault(remoteBranch.getName(), new RepositoryBranch());
|
RepositoryBranch branch = existingBranchMap.getOrDefault(remoteBranch.getName(), new RepositoryBranch());
|
||||||
|
|
||||||
|
// 获取对应的RepositoryProject以获取GitLab的真实project_id
|
||||||
|
RepositoryProject project = repositoryProjectRepository.findById(projectId)
|
||||||
|
.orElseThrow(() -> new BusinessException(ResponseCode.REPOSITORY_PROJECT_NOT_FOUND));
|
||||||
|
|
||||||
// 更新基本信息
|
// 更新基本信息
|
||||||
branch.setExternalSystemId(externalSystemId);
|
branch.setExternalSystemId(externalSystemId);
|
||||||
branch.setProjectId(projectId);
|
branch.setProjectId(projectId); // 设置我们数据库的project ID
|
||||||
|
branch.setGitProjectId(project.getProjectId()); // 设置GitLab的真实project ID
|
||||||
branch.setName(remoteBranch.getName());
|
branch.setName(remoteBranch.getName());
|
||||||
branch.setIsDefaultBranch(remoteBranch.getIsDefaultBranch());
|
branch.setIsDefaultBranch(remoteBranch.getIsDefaultBranch());
|
||||||
branch.setCanPush(remoteBranch.getCanPush());
|
branch.setCanPush(remoteBranch.getCanPush());
|
||||||
|
|||||||
@ -339,30 +339,33 @@ CREATE TABLE deploy_repo_branch
|
|||||||
(
|
(
|
||||||
-- 基础字段
|
-- 基础字段
|
||||||
id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '主键ID',
|
id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '主键ID',
|
||||||
create_by VARCHAR(100) NULL COMMENT '创建人',
|
|
||||||
create_time DATETIME(6) NULL COMMENT '创建时间',
|
|
||||||
update_by VARCHAR(100) NULL COMMENT '更新人',
|
|
||||||
update_time DATETIME(6) NULL COMMENT '更新时间',
|
|
||||||
version INT NOT NULL DEFAULT 1 COMMENT '版本号',
|
|
||||||
deleted BIT NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除,1-已删除',
|
|
||||||
|
|
||||||
-- 业务字段
|
-- 业务字段
|
||||||
name VARCHAR(100) NOT NULL COMMENT '分支名称',
|
name VARCHAR(100) NOT NULL COMMENT '分支名称',
|
||||||
project_id BIGINT NOT NULL COMMENT '所属项目ID',
|
|
||||||
external_system_id BIGINT NOT NULL COMMENT '外部系统ID',
|
|
||||||
is_default_branch BIT DEFAULT 0 COMMENT '是否为默认分支:0-否,1-是',
|
is_default_branch BIT DEFAULT 0 COMMENT '是否为默认分支:0-否,1-是',
|
||||||
can_push BIT DEFAULT 1 COMMENT '是否可推送:0-否,1-是',
|
can_push BIT DEFAULT 1 COMMENT '是否可推送:0-否,1-是',
|
||||||
developers_can_push BIT DEFAULT 1 COMMENT '开发者是否可推送:0-否,1-是',
|
developers_can_push BIT DEFAULT 1 COMMENT '开发者是否可推送:0-否,1-是',
|
||||||
developers_can_merge BIT DEFAULT 1 COMMENT '开发者是否可合并:0-否,1-是',
|
developers_can_merge BIT DEFAULT 1 COMMENT '开发者是否可合并:0-否,1-是',
|
||||||
commit_id VARCHAR(64) NULL COMMENT '最新提交ID',
|
commit_id VARCHAR(64) NULL COMMENT '最新提交ID',
|
||||||
commit_message TEXT NULL COMMENT '最新提交信息',
|
commit_message TEXT NULL COMMENT '最新提交信息',
|
||||||
commit_author VARCHAR(100) NULL COMMENT '最新提交作者',
|
commit_author VARCHAR(100) NULL COMMENT '最新提交作者',
|
||||||
commit_date DATETIME(6) NULL COMMENT '最新提交时间',
|
commit_date DATETIME(6) NULL COMMENT '最新提交时间',
|
||||||
last_update_time DATETIME(6) NULL COMMENT '分支最后更新时间',
|
last_update_time DATETIME(6) NULL COMMENT '分支最后更新时间',
|
||||||
last_commit_time DATETIME(6) NULL COMMENT '分支最后提交时间',
|
last_commit_time DATETIME(6) NULL COMMENT '分支最后提交时间',
|
||||||
web_url VARCHAR(255) NULL COMMENT '网页URL'
|
web_url VARCHAR(255) NULL COMMENT '网页URL',
|
||||||
|
project_id BIGINT NOT NULL COMMENT '所属项目ID',
|
||||||
|
external_system_id BIGINT NOT NULL COMMENT '外部系统ID',
|
||||||
|
git_project_id BIGINT NOT NULL COMMENT 'GitLab的真实project_id',
|
||||||
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='代码仓库分支表';
|
create_by VARCHAR(100) NULL COMMENT '创建人',
|
||||||
|
create_time DATETIME(6) NULL COMMENT '创建时间',
|
||||||
|
update_by VARCHAR(100) NULL COMMENT '更新人',
|
||||||
|
update_time DATETIME(6) NULL COMMENT '更新时间',
|
||||||
|
version INT NOT NULL DEFAULT 1 COMMENT '版本号',
|
||||||
|
deleted BIT NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除,1-已删除'
|
||||||
|
|
||||||
|
) ENGINE = InnoDB
|
||||||
|
DEFAULT CHARSET = utf8mb4
|
||||||
|
COLLATE = utf8mb4_unicode_ci COMMENT ='代码仓库分支表';
|
||||||
|
|
||||||
-- --------------------------------------------------------------------------------------
|
-- --------------------------------------------------------------------------------------
|
||||||
-- 工作流相关表
|
-- 工作流相关表
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user