From 085e069cb7bf43438ff88308bb05cf4cd2e1f63b Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Wed, 12 Apr 2023 21:10:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8DGit=E6=96=87=E4=BB=B6=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E5=85=B6=E4=BB=96=E5=88=86=E6=94=AF=E6=96=87=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E6=96=87=E4=BB=B6=E5=B7=B2=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=9A=84bug=EF=BC=8C=E5=B9=B6=E5=9C=A8=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=B1=95=E7=A4=BAgit=E6=96=87=E4=BB=B6=E6=97=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=86=E6=94=AF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1025343 --user=宋天阳 [项目管理] github#23586git文件上传不同分支,同一路径文件拉取失败报文件已存在 https://www.tapd.cn/55049933/s/1362041 --- .../metadata/service/FileMetadataService.java | 25 +++++++++++++------ .../menu/file/list/FileMetadataList.vue | 20 +++++++++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/metadata/service/FileMetadataService.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/metadata/service/FileMetadataService.java index f2367d6e95..74eccb2dd9 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/metadata/service/FileMetadataService.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/metadata/service/FileMetadataService.java @@ -97,17 +97,26 @@ public class FileMetadataService { return result; } - private void validateGitFile(FileMetadataCreateRequest fileMetadata) { - if (StringUtils.isEmpty(fileMetadata.getModuleId())) { + private void validateGitFile(FileMetadataCreateRequest validateModel) { + if (StringUtils.isEmpty(validateModel.getModuleId())) { MSException.throwException(Translator.get("test_case_module_not_null")); } else { FileMetadataExample example = new FileMetadataExample(); - example.createCriteria().andModuleIdEqualTo(fileMetadata.getModuleId()) - .andStorageEqualTo(fileMetadata.getStorage()) - .andPathEqualTo(fileMetadata.getRepositoryPath()) - .andIdNotEqualTo(fileMetadata.getId()); - if (fileMetadataMapper.countByExample(example) > 0) { - MSException.throwException(Translator.get("project_file_already_exists")); + example.createCriteria().andModuleIdEqualTo(validateModel.getModuleId()) + .andStorageEqualTo(validateModel.getStorage()) + .andPathEqualTo(validateModel.getRepositoryPath()) + .andIdNotEqualTo(validateModel.getId()); + List fileMetadataWithBLOBsList = fileMetadataMapper.selectByExampleWithBLOBs(example); + for (FileMetadataWithBLOBs fileMetadataWithBlobs : fileMetadataWithBLOBsList) { + RemoteFileAttachInfo gitFileInfo = null; + try { + gitFileInfo = JSON.parseObject(fileMetadataWithBlobs.getAttachInfo(), RemoteFileAttachInfo.class); + } catch (Exception e) { + LogUtil.error("解析git信息失败!", e); + } + if (StringUtils.equals(gitFileInfo.getBranch(), validateModel.getRepositoryBranch())) { + MSException.throwException(Translator.get("project_file_already_exists")); + } } } } diff --git a/project-management/frontend/src/business/menu/file/list/FileMetadataList.vue b/project-management/frontend/src/business/menu/file/list/FileMetadataList.vue index 8f26092d57..c23c68274c 100644 --- a/project-management/frontend/src/business/menu/file/list/FileMetadataList.vue +++ b/project-management/frontend/src/business/menu/file/list/FileMetadataList.vue @@ -53,6 +53,21 @@ :min-width="120" :label="$t('load_test.file_name')" > + {