fix(项目管理): 修复存储库文件更新时没有获取到最新commit的缺陷
--bug=1035308 --user=宋天阳 【用例管理】-用例关联文件,文件详情页关联用例列表中,用例关联的文件版本显示错误 https://www.tapd.cn/55049933/s/1460285
This commit is contained in:
parent
370fc1661f
commit
2ad4ca9d0d
|
@ -140,11 +140,10 @@ public class GitRepositoryUtil {
|
||||||
|
|
||||||
private String getFileLastCommitId(ObjectId objectId, String filePath) throws Exception {
|
private String getFileLastCommitId(ObjectId objectId, String filePath) throws Exception {
|
||||||
Iterable<RevCommit> logs = git.log().add(objectId).addPath(filePath).call();
|
Iterable<RevCommit> logs = git.log().add(objectId).addPath(filePath).call();
|
||||||
String returnStr = StringUtils.EMPTY;
|
|
||||||
for (RevCommit rev : logs) {
|
for (RevCommit rev : logs) {
|
||||||
returnStr = rev.getName();
|
return rev.getName();
|
||||||
}
|
}
|
||||||
return returnStr;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private RevCommit getRevTreeByRepositoryAndCommitId(InMemoryRepository repo, ObjectId fileCommitId) throws Exception {
|
private RevCommit getRevTreeByRepositoryAndCommitId(InMemoryRepository repo, ObjectId fileCommitId) throws Exception {
|
||||||
|
|
|
@ -532,13 +532,16 @@ public class FileMetadataService {
|
||||||
private void setFileVersionIsOld(FileMetadata oldFile, String operator) {
|
private void setFileVersionIsOld(FileMetadata oldFile, String operator) {
|
||||||
//删除旧的预览文件
|
//删除旧的预览文件
|
||||||
TempFileUtils.deleteTmpFile(oldFile.getId());
|
TempFileUtils.deleteTmpFile(oldFile.getId());
|
||||||
//更新文件版本分支
|
//通过refId批量更新
|
||||||
|
FileMetadataExample example = new FileMetadataExample();
|
||||||
|
example.createCriteria().andRefIdEqualTo(oldFile.getRefId()).andLatestEqualTo(true);
|
||||||
|
|
||||||
FileMetadata updateModel = new FileMetadata();
|
FileMetadata updateModel = new FileMetadata();
|
||||||
updateModel.setId(oldFile.getId());
|
|
||||||
updateModel.setLatest(false);
|
updateModel.setLatest(false);
|
||||||
updateModel.setUpdateTime(System.currentTimeMillis());
|
updateModel.setUpdateTime(System.currentTimeMillis());
|
||||||
updateModel.setUpdateUser(operator);
|
updateModel.setUpdateUser(operator);
|
||||||
fileMetadataMapper.updateByPrimaryKeySelective(updateModel);
|
|
||||||
|
fileMetadataMapper.updateByExampleSelective(updateModel, example);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void genNewFileVersionByOldFile(FileMetadata oldFile, FileMetadata fileMetadata, String operator) {
|
private void genNewFileVersionByOldFile(FileMetadata oldFile, FileMetadata fileMetadata, String operator) {
|
||||||
|
@ -620,6 +623,7 @@ public class FileMetadataService {
|
||||||
//获取fileMetadata以及可能存在的fileMetadataRepository
|
//获取fileMetadata以及可能存在的fileMetadataRepository
|
||||||
FileMetadataExample example = new FileMetadataExample();
|
FileMetadataExample example = new FileMetadataExample();
|
||||||
example.createCriteria().andRefIdEqualTo(fileMetadata.getRefId());
|
example.createCriteria().andRefIdEqualTo(fileMetadata.getRefId());
|
||||||
|
example.setOrderByClause(" create_time DESC ");
|
||||||
List<FileMetadata> fileMetadataList = fileMetadataMapper.selectByExample(example);
|
List<FileMetadata> fileMetadataList = fileMetadataMapper.selectByExample(example);
|
||||||
List<String> fileIdList = fileMetadataList.stream().map(FileMetadata::getId).toList();
|
List<String> fileIdList = fileMetadataList.stream().map(FileMetadata::getId).toList();
|
||||||
FileMetadataRepositoryExample repositoryExample = new FileMetadataRepositoryExample();
|
FileMetadataRepositoryExample repositoryExample = new FileMetadataRepositoryExample();
|
||||||
|
|
Loading…
Reference in New Issue