forked from Gitlink/microservices
Merge pull request 'feat(超算专区): 获取项目聚合列表时,若项目为镜像项目则返回项目的镜像owner' (#1099) from otto/microservices:chaosuan_zone into chaosuan_zone
This commit is contained in:
commit
1ea5e87767
|
|
@ -214,6 +214,24 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
|
|||
}
|
||||
}
|
||||
|
||||
private static String extractFirstPathSegment(String url) {
|
||||
if (url == null || url.isEmpty()) return null;
|
||||
|
||||
// 找到协议后的第一个 '/' 的位置(路径开始)
|
||||
int schemeSep = url.indexOf("://");
|
||||
if (schemeSep == -1) return null;
|
||||
|
||||
int hostStart = schemeSep + 3;
|
||||
int pathStart = url.indexOf('/', hostStart);
|
||||
if (pathStart == -1) return null; // 没有路径
|
||||
|
||||
// 找到下一个 '/' 或结尾
|
||||
int pathEnd = url.indexOf('/', pathStart + 1);
|
||||
if (pathEnd == -1) pathEnd = url.length();
|
||||
|
||||
return url.substring(pathStart + 1, pathEnd);
|
||||
}
|
||||
|
||||
private ZoneProjectDataVo zoneProjectToZoneProjectDataVo(ZoneProject zoneProject, JSONObject gitLinkProject) {
|
||||
//每次从GitLink查询项目时自动更新项目名称和项目标识
|
||||
updateProjectNameAndFullName(gitLinkProject, zoneProject);
|
||||
|
|
@ -233,6 +251,11 @@ public class ZoneProjectServiceImpl implements IZoneProjectService {
|
|||
projectKeyName.put("name", "项目名称");
|
||||
projectPropertiesVo.put("fullName", author.getString("login") + "/" + gitLinkProject.getString("identifier"));
|
||||
projectKeyName.put("fullName", "项目完整地址");
|
||||
projectPropertiesVo.put("fromOwner", author.getString("login"));
|
||||
}
|
||||
String mirrorUrl = gitLinkProject.getString("mirror_url");
|
||||
if (StringUtils.isNotEmpty(mirrorUrl)) {
|
||||
projectPropertiesVo.put("fromOwner", extractFirstPathSegment(mirrorUrl));
|
||||
}
|
||||
String description = gitLinkProject.getString("description");
|
||||
projectPropertiesVo.put("description", description);
|
||||
|
|
|
|||
Loading…
Reference in New Issue