Skip to content

Commit d6ccaa6

Browse files
committed
Coords: version prefix (:) is removed if has version but toString'ed with empty version
1 parent 8949407 commit d6ccaa6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/main/java/org/scm4j/commons/Coords.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ public Version getVersion() {
111111

112112
@Override
113113
public String toString() {
114-
return toString(version.toString());
114+
return getName() + verPrefix + version.toString() + verSuffix + classifier + extension + commentStr;
115115
}
116116

117117
public String toString(String versionStr) {
118-
String str = verPrefix.isEmpty() && !versionStr.isEmpty() ? ":" : verPrefix;
118+
String str = verPrefix.isEmpty() && !versionStr.isEmpty() ? ":" : verSuffix.isEmpty() && versionStr.isEmpty() ? "" : verPrefix;
119119
str += versionStr + verSuffix + classifier + extension;
120120
return getName() + str + commentStr;
121121
}

src/test/java/org/scm4j/commons/CoordsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void testVersionChange() {
9292
assertEquals("eu.untill:JTerminal:12.13:abc@efg # comment", new Coords("eu.untill:JTerminal::abc@efg # comment").toString("12.13"));
9393
assertEquals("eu.untill:JTerminal::abc@efg # comment", new Coords("eu.untill:JTerminal:12.13:abc@efg # comment").toString(""));
9494
assertEquals("eu.untill:JTerminal::# comment", new Coords("eu.untill:JTerminal:12.13:# comment").toString(""));
95-
assertEquals("eu.untill:JTerminal: # comment", new Coords("eu.untill:JTerminal:12.13 # comment").toString(""));
95+
assertEquals("eu.untill:JTerminal # comment", new Coords("eu.untill:JTerminal:12.13 # comment").toString(""));
9696
assertEquals("eu.untill:JTerminal # comment", new Coords("eu.untill:JTerminal # comment").toString(""));
9797
assertEquals("eu.untill:JTerminal:12.13 # comment", new Coords("eu.untill:JTerminal # comment").toString("12.13"));
9898
}

0 commit comments

Comments
 (0)