fix: ASW-134 application 名称从 git 目录中获取
This commit is contained in:
@@ -45,6 +45,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -523,23 +524,24 @@ public class GitServiceImpl implements IGitService {
|
|||||||
|
|
||||||
List<CompletableFuture<Map>> futureList = T.ListUtil.list(false);
|
List<CompletableFuture<Map>> futureList = T.ListUtil.list(false);
|
||||||
while (treeWalk.next()) {
|
while (treeWalk.next()) {
|
||||||
|
String filePath = treeWalk.getPathString();
|
||||||
String fileName = treeWalk.getNameString();
|
String fileName = treeWalk.getNameString();
|
||||||
if (T.StrUtil.equals("meta.json", fileName)) {
|
if (T.StrUtil.equals("meta.json", fileName)) {
|
||||||
|
// application_name 从目录中获取
|
||||||
|
String applicationName = T.PathUtil.getPathEle(Path.of(filePath), 1).toString();
|
||||||
|
// filter by name
|
||||||
|
if (T.StrUtil.isNotEmpty(q) && !T.StrUtil.containsIgnoreCase(applicationName, q)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ObjectLoader loader = repository.open(treeWalk.getObjectId(0));
|
ObjectLoader loader = repository.open(treeWalk.getObjectId(0));
|
||||||
String metaJsonStr = T.StrUtil.utf8Str(loader.getBytes());
|
String metaJsonStr = T.StrUtil.utf8Str(loader.getBytes());
|
||||||
metaJsonStr = T.StrUtil.emptyToDefault(metaJsonStr, T.StrUtil.EMPTY_JSON);
|
metaJsonStr = T.StrUtil.emptyToDefault(metaJsonStr, T.StrUtil.EMPTY_JSON);
|
||||||
Map metaJsonMap = T.JSONUtil.toBean(metaJsonStr, Map.class);
|
Map metaJsonMap = T.JSONUtil.toBean(metaJsonStr, Map.class);
|
||||||
|
|
||||||
// filter by name
|
|
||||||
if (T.StrUtil.isNotEmpty(q)) {
|
|
||||||
String appName = T.MapUtil.getStr(metaJsonMap, "name", "");
|
|
||||||
if (!T.StrUtil.containsIgnoreCase(appName, q)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<Object, Object> m = T.MapUtil.newHashMap(true);
|
Map<Object, Object> m = T.MapUtil.newHashMap(true);
|
||||||
m.putAll(metaJsonMap);
|
m.putAll(metaJsonMap);
|
||||||
|
m.put("name", applicationName);
|
||||||
|
|
||||||
String appId = T.MapUtil.getStr(metaJsonMap, "id", "");
|
String appId = T.MapUtil.getStr(metaJsonMap, "id", "");
|
||||||
String appDirPath = treeWalk.getPathString().replaceAll(fileName, "");
|
String appDirPath = treeWalk.getPathString().replaceAll(fileName, "");
|
||||||
|
|||||||
Reference in New Issue
Block a user