Skip to content

Commit

Permalink
trying to fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dfa1 committed Dec 19, 2023
1 parent a945df7 commit cc23511
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions runtime/src/test/java/hosh/runtime/VersionLoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/
package hosh.runtime;

import hosh.spi.*;
import hosh.spi.Version;
import org.junit.jupiter.api.Test;

import java.io.IOException;
Expand All @@ -32,10 +32,10 @@

class VersionLoaderTest {

@Test
void loadVersionViaGit() throws IOException {
Version result= VersionLoader.loadVersion();
assertThat(result).isNotNull(); // must be always defined
}
@Test
void loadVersionViaGit() throws IOException {
Version result = VersionLoader.loadVersion();
assertThat(result).isNotNull(); // must be always defined
}

}
16 changes: 8 additions & 8 deletions spi/src/main/java/hosh/spi/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ public class Version {

private final String value;

public Version(String value) {
if (value == null) {
public Version(String candidate) {
if (candidate == null) {
throw new IllegalArgumentException("null version");
}
if (value.isBlank()) {
if (candidate.isBlank()) {
throw new IllegalArgumentException("empty version");
}
final String[] split = value.split("\\.");
final String[] split = candidate.split("\\.");
if (!split[0].startsWith("v")) {
throw new IllegalArgumentException("missing prefix");
throw new IllegalArgumentException("missing prefix: " + candidate);
}
if (split.length != 3) { // expecting to follow our maven conventions of major.minor.patch
throw new IllegalArgumentException("invalid maven version");
throw new IllegalArgumentException("invalid maven version: " + candidate);
}
// at this point value is fully validated, but it is never exposed directly
this.value = value;
// at this point candidate is fully validated
this.value = candidate;
}

/**
Expand Down

0 comments on commit cc23511

Please sign in to comment.