Skip to content

Commit

Permalink
WHY THEY ALLOW NULL NAMES EXISTENCE
Browse files Browse the repository at this point in the history
  • Loading branch information
45gfg9 committed May 25, 2020
1 parent cb669ae commit 3d35957
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'net.im45.bot'
version = '0.2.5'
version = '0.2.6'

repositories {
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
Expand All @@ -22,10 +22,10 @@ dependencies {
}

compileKotlin {
kotlinOptions.jvmTarget = '11'
kotlinOptions.jvmTarget = JavaVersion.VERSION_11
}
compileTestKotlin {
kotlinOptions.jvmTarget = '11'
kotlinOptions.jvmTarget = JavaVersion.VERSION_11
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_11
6 changes: 5 additions & 1 deletion src/main/java/net/im45/bot/watcher/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public static Optional<Release> parseRelease(JsonElement jsonElement) throws Rep
// or GitHub changed the format
throw new RuntimeException(e);
}
latest.authorName = author.get("name").getAsString();

latest.authorName = Optional.of(author.get("name"))
.filter(JsonElement::isJsonPrimitive)
.map(JsonElement::getAsString)
.orElse("null");
latest.authorLogin = author.get("login").getAsString();
latest.assets = new ArrayList<>(assetsCount);
assets.forEach(e -> {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/im45/bot/watcher/Request.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ public void run() {
if (Parser.hasErrors(jsonElement)) {
err.accept("Error received from upstream");
JsonArray jsonArray = Parser.getErrors(jsonElement);
debug.accept(jsonArray.toString());
err.accept(jsonArray.toString());
// debug.accept(jsonElement.toString());
}
if (!Parser.hasData(jsonElement)) {
err.accept("Error! Received data doesn't have a \"data\" object");
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/im45/bot/watcher/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static Map<RepoId, Pair<Release, Set<Long>>> filterNew(
// update current
ver.put(r, Pair.of(release.tagName, p.second));
if (!p.first.equals("?")) {
// not first time...
// not first time, notice 'em
map.put(r, Pair.of(release, p.second));
}
}
Expand All @@ -84,7 +84,7 @@ public static Map<RepoId, Pair<Release, Set<Long>>> filterNew(
/**
* Converts number of bytes to corresponding representations.
* <p>
* That is, {@code 3530} becomes {@code 3.53}KB and some such.
* That is, {@code 3530} becomes {@code 3.53KB} and some such.
*
* @param bytes number of bytes
* @throws IllegalArgumentException if given number is negative
Expand Down Expand Up @@ -117,14 +117,14 @@ public static Path getResource(Class<?> clazz, String resource) throws URISyntax
case "file":
return Paths.get(uri);
case "jar":
return FileSystems.newFileSystem(uri, Collections.emptyMap()).getPath(resource);
return FileSystems.newFileSystem(uri, Map.of()).getPath(resource);
default:
throw new IllegalStateException("Unknown scheme: " + scheme);
}
}

/**
* Converts a RepoId to a legal identifier.
* Converts a {@code RepoId} to a legal identifier.
*
* @param repoId A {@link RepoId} object
* @return The corresponding identifier
Expand All @@ -133,7 +133,7 @@ public static Path getResource(Class<?> clazz, String resource) throws URISyntax
public static String toLegalId(RepoId repoId) {
// No starting with numbers and no special characters.
return repoId.toString()
.replaceAll("^(\\d)", "_$1")
.replaceFirst("^(\\d)", "_$1")
.replaceAll("[-/.]", "_");
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: "release-watcher"
author: "45gfg9"
version: "0.2.5"
version: "0.2.6"
main: "net.im45.bot.watcher.Watcher"
info: ""
depends: []

0 comments on commit 3d35957

Please sign in to comment.