Skip to content

Commit 3c8d8f8

Browse files
committed
release 1.0.0
1 parent 2937388 commit 3c8d8f8

File tree

4 files changed

+64
-66
lines changed

4 files changed

+64
-66
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>org.nqm</groupId>
66
<artifactId>gis</artifactId>
7-
<version>1.0.0-beta</version>
7+
<version>1.0.0</version>
88
<packaging>${packaging}</packaging>
99

1010
<properties>

src/main/java/org/nqm/Gis.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
name = "gis",
1212
description = "Git extension wrapper which supports submodules",
1313
mixinStandardHelpOptions = true,
14-
version = "1.0.0-beta")
14+
version = "1.0.0")
1515
public class Gis extends GitCommand {
1616

1717
@Option(names = "-v", description = "Show more details information.", scope = ScopeType.INHERIT)

src/main/java/org/nqm/utils/StdOutUtils.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import static java.lang.System.err; // NOSONAR
44
import static java.lang.System.out; // NOSONAR
5+
import static java.util.function.Predicate.not;
6+
import java.util.Optional;
7+
import java.util.function.UnaryOperator;
8+
import java.util.stream.Collectors;
9+
import java.util.stream.Stream;
510

611
public class StdOutUtils {
712

@@ -40,4 +45,60 @@ public static String coloringWord(String word, String color) {
4045
public static String coloringWord(Character c, String color) {
4146
return color + c + CL_RESET;
4247
}
48+
49+
public static String buildStaging(char[] chars) {
50+
return Optional.of(chars[0])
51+
.map(s -> s != '.' ? coloringWord(s, CL_GREEN) : s + "")
52+
.orElse("") +
53+
Optional.of(chars[1])
54+
.map(s -> s != '.' ? coloringWord(s, CL_RED) : s + "")
55+
.orElse("")
56+
+ " ";
57+
}
58+
59+
private static String buildAheadBehind(String[] splitS) {
60+
var ahead = Optional.of(splitS[2])
61+
.map(s -> s.replace("+", ""))
62+
.filter(not("0"::equals))
63+
.map(s -> "ahead " + coloringWord(s, CL_GREEN))
64+
.orElse("");
65+
var behind = Optional.of(splitS[3])
66+
.map(s -> s.replace("-", ""))
67+
.filter(not("0"::equals))
68+
.map(s -> "behind " + coloringWord(s, CL_RED))
69+
.orElse("");
70+
return Stream.of(ahead, behind).filter(not(String::isBlank)).collect(Collectors.joining(", "));
71+
}
72+
73+
public static String gitStatus(String line) {
74+
var sb = new StringBuilder();
75+
if (line.startsWith("# branch.oid")) {
76+
return "";
77+
}
78+
if (line.startsWith("# branch.head")) {
79+
sb.append("\n ## ").append(coloringWord(line.split("\s")[2], CL_GREEN));
80+
}
81+
else if (line.startsWith("# branch.upstream")) {
82+
sb.append("...").append(coloringWord(line.split("\s")[2], CL_RED));
83+
}
84+
else if (line.startsWith("# branch.ab")) {
85+
Optional.of(line.split("\s"))
86+
.map(StdOutUtils::buildAheadBehind)
87+
.filter(GisStringUtils::isNotBlank)
88+
.map(" [%s]"::formatted)
89+
.ifPresent(sb::append);
90+
}
91+
else {
92+
final var immutableLine = line;
93+
UnaryOperator<String> getFiles = filesChange -> immutableLine.startsWith("2")
94+
? Optional.of(filesChange.split("\t")).map(s -> s[1] + " -> " + s[0]).orElse("")
95+
: filesChange;
96+
97+
Optional.of(line.split("\s"))
98+
.ifPresent(splitS -> sb.append("\n ")
99+
.append(Optional.of(splitS[1].toCharArray()).map(StdOutUtils::buildStaging).orElse(""))
100+
.append(Optional.of(splitS[splitS.length - 1]).map(getFiles).orElse("")));
101+
}
102+
return sb.toString();
103+
}
43104
}

src/main/java/org/nqm/vertx/CommandVerticle.java

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,18 @@
11
package org.nqm.vertx;
22

33
import static java.lang.System.out; // NOSONAR
4-
import static java.util.function.Predicate.not;
54
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;
95
import static org.nqm.utils.StdOutUtils.errln;
6+
import static org.nqm.utils.StdOutUtils.gitStatus;
107
import static org.nqm.utils.StdOutUtils.infof;
118
import static org.nqm.utils.StdOutUtils.warnln;
129
import java.io.BufferedReader;
1310
import java.io.IOException;
1411
import java.io.InputStreamReader;
1512
import java.nio.file.Path;
1613
import java.util.Optional;
17-
import java.util.function.UnaryOperator;
18-
import java.util.stream.Collectors;
19-
import java.util.stream.Stream;
2014
import org.nqm.config.GisConfig;
2115
import org.nqm.config.GisLog;
22-
import org.nqm.utils.GisStringUtils;
2316
import io.vertx.core.AbstractVerticle;
2417
import io.vertx.core.Promise;
2518

@@ -93,60 +86,4 @@ private void safelyPrint(Process pr) {
9386
Thread.currentThread().interrupt();
9487
}
9588
}
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-
}
15289
}

0 commit comments

Comments
 (0)