formatGitLog function
Implementation
String formatGitLog(String flutterLog, String unityLog) {
List<String> filterLogs(String log) {
List<String> logs = [];
for (var log in log.split("\n")) {
/// 如果当前行存在以下关键字 则忽略
if (['commit', 'Author', 'Date', 'Merge', '# Conflicts', '# ']
.any((e) => log.toLowerCase().startsWith(e.toLowerCase()))) {
continue;
}
logs.add(log);
}
return logs;
}
List<String> logs = [];
final flutterLogs = filterLogs(flutterLog);
final unityLogs = filterLogs(unityLog);
if (flutterLogs.length + unityLogs.length > 100) {
logs.addAll(unityLogs.sublist(0, max(unityLogs.length, 30)));
logs.addAll(flutterLogs.sublist(0, max(flutterLogs.length, 30)));
} else {
logs.addAll(unityLogs);
logs.addAll(flutterLogs);
}
return logs.join('\n');
}