|
1 | 1 | package org.nqm.vertx; |
2 | 2 |
|
3 | 3 | import static java.lang.System.out; // NOSONAR |
4 | | -import static java.util.function.Predicate.not; |
5 | 4 | import static org.nqm.utils.GisStringUtils.isNotBlank; |
6 | | -import static org.nqm.utils.StdOutUtils.CL_GREEN; |
7 | | -import static org.nqm.utils.StdOutUtils.CL_RED; |
8 | | -import static org.nqm.utils.StdOutUtils.coloringWord; |
9 | 5 | import static org.nqm.utils.StdOutUtils.errln; |
| 6 | +import static org.nqm.utils.StdOutUtils.gitStatus; |
10 | 7 | import static org.nqm.utils.StdOutUtils.infof; |
11 | 8 | import static org.nqm.utils.StdOutUtils.warnln; |
12 | 9 | import java.io.BufferedReader; |
13 | 10 | import java.io.IOException; |
14 | 11 | import java.io.InputStreamReader; |
15 | 12 | import java.nio.file.Path; |
16 | 13 | import java.util.Optional; |
17 | | -import java.util.function.UnaryOperator; |
18 | | -import java.util.stream.Collectors; |
19 | | -import java.util.stream.Stream; |
20 | 14 | import org.nqm.config.GisConfig; |
21 | 15 | import org.nqm.config.GisLog; |
22 | | -import org.nqm.utils.GisStringUtils; |
23 | 16 | import io.vertx.core.AbstractVerticle; |
24 | 17 | import io.vertx.core.Promise; |
25 | 18 |
|
@@ -93,60 +86,4 @@ private void safelyPrint(Process pr) { |
93 | 86 | Thread.currentThread().interrupt(); |
94 | 87 | } |
95 | 88 | } |
96 | | - |
97 | | - private static String gitStatus(String line) { |
98 | | - var sb = new StringBuilder(); |
99 | | - if (line.startsWith("# branch.oid")) { |
100 | | - return ""; |
101 | | - } |
102 | | - if (line.startsWith("# branch.head")) { |
103 | | - sb.append("\n ## ").append(coloringWord(line.split("\s")[2], CL_GREEN)); |
104 | | - } |
105 | | - else if (line.startsWith("# branch.upstream")) { |
106 | | - sb.append("...").append(coloringWord(line.split("\s")[2], CL_RED)); |
107 | | - } |
108 | | - else if (line.startsWith("# branch.ab")) { |
109 | | - Optional.of(line.split("\s")) |
110 | | - .map(CommandVerticle::buildAheadBehind) |
111 | | - .filter(GisStringUtils::isNotBlank) |
112 | | - .map(" [%s]"::formatted) |
113 | | - .ifPresent(sb::append); |
114 | | - } |
115 | | - else { |
116 | | - final var immutableLine = line; |
117 | | - UnaryOperator<String> getFiles = filesChange -> immutableLine.startsWith("2") |
118 | | - ? Optional.of(filesChange.split("\t")).map(s -> s[1] + " -> " + s[0]).orElse("") |
119 | | - : filesChange; |
120 | | - |
121 | | - Optional.of(line.split("\s")) |
122 | | - .ifPresent(splitS -> sb.append("\n ") |
123 | | - .append(Optional.of(splitS[1].toCharArray()).map(CommandVerticle::buildStaging).orElse("")) |
124 | | - .append(Optional.of(splitS[splitS.length - 1]).map(getFiles).orElse(""))); |
125 | | - } |
126 | | - return sb.toString(); |
127 | | - } |
128 | | - |
129 | | - private static String buildAheadBehind(String[] splitS) { |
130 | | - var ahead = Optional.of(splitS[2]) |
131 | | - .map(s -> s.replace("+", "")) |
132 | | - .filter(not("0"::equals)) |
133 | | - .map(s -> "ahead " + coloringWord(s, CL_GREEN)) |
134 | | - .orElse(""); |
135 | | - var behind = Optional.of(splitS[3]) |
136 | | - .map(s -> s.replace("-", "")) |
137 | | - .filter(not("0"::equals)) |
138 | | - .map(s -> "behind " + coloringWord(s, CL_RED)) |
139 | | - .orElse(""); |
140 | | - return Stream.of(ahead, behind).filter(not(String::isBlank)).collect(Collectors.joining(", ")); |
141 | | - } |
142 | | - |
143 | | - private static String buildStaging(char[] chars) { |
144 | | - return Optional.of(chars[0]) |
145 | | - .map(s -> s != '.' ? coloringWord(s, CL_GREEN) : s + "") |
146 | | - .orElse("") + |
147 | | - Optional.of(chars[1]) |
148 | | - .map(s -> s != '.' ? coloringWord(s, CL_RED) : s + "") |
149 | | - .orElse("") |
150 | | - + " "; |
151 | | - } |
152 | 89 | } |
0 commit comments