Skip to content

Commit 4276694

Browse files
committed
Remove "v" prefix from tags and version
1 parent 9d0a24b commit 4276694

2 files changed

Lines changed: 8 additions & 16 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Create Release
33
on:
44
push:
55
tags:
6-
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6+
- '*'
77

88
jobs:
99
build:
@@ -30,7 +30,7 @@ jobs:
3030
release_name: Release ${{ github.ref }}
3131
body: |
3232
Changes in this Release
33-
- Update for new companion app version
33+
- 1.7.10 release
3434
draft: false
3535
prerelease: false
3636
- name: Upload jars to release

src/main/java/com/github/minecraft_ta/totaldebug/companionApp/CompanionApp.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.apache.commons.lang3.StringUtils;
3232
import org.apache.http.HttpEntity;
3333
import org.apache.http.HttpResponse;
34-
import org.apache.http.client.HttpClient;
3534
import org.apache.http.client.methods.HttpGet;
3635
import org.apache.http.impl.client.CloseableHttpClient;
3736
import org.apache.http.impl.client.HttpClients;
@@ -154,7 +153,7 @@ public void startAndConnect() {
154153
ICommandSender sender = Minecraft.getMinecraft().thePlayer;
155154

156155
if (!isRunning()) {
157-
if (!Metafile.areVersionsCompatible("v" + Tags.VERSION, this.metafile.currentCompanionAppVersion)) {
156+
if (!Metafile.areVersionsCompatible(Tags.VERSION, this.metafile.currentCompanionAppVersion)) {
158157
this.metafile.loadNewestCompanionAppVersion();
159158
} else {
160159
// If the current versions are compatible, it's fine if we download the new version after the next
@@ -305,9 +304,8 @@ private void downloadCompanionApp(String version) {
305304
.setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GRAY))
306305
);
307306

308-
HttpClient client = HttpClients.createDefault();
309307
HttpResponse response;
310-
try {
308+
try (CloseableHttpClient client = HttpClients.createDefault()) {
311309
response = client.execute(new HttpGet("https://github.com/Minecraft-TA/TotalDebugCompanion/releases/download/" + version + "/TotalDebugCompanion.zip"));
312310
} catch (IOException e) {
313311
TotalDebug.LOGGER.error("Unable to reach github. Does this release exist? " + version, e);
@@ -508,15 +506,14 @@ private void loadNewestCompanionAppVersion() {
508506
byte[] responseData = outputStream.toByteArray();
509507

510508
JsonArray jsonArray = GSON.fromJson(new String(responseData, StandardCharsets.UTF_8), JsonArray.class);
511-
String totalDebugVersion = "v" + Tags.VERSION;
512509

513-
//find newest matching version
510+
// Find newest matching version
514511
for (int i = 0; i < jsonArray.size(); i++) {
515512
JsonObject jsonObject = jsonArray.get(i).getAsJsonObject();
516513
String version = jsonObject.get("tag_name").getAsString();
517514

518-
//don't compare build number
519-
if (areVersionsCompatible(totalDebugVersion, version)) {
515+
// Don't compare build number
516+
if (areVersionsCompatible(Tags.VERSION, version)) {
520517
TotalDebug.LOGGER.info("Found matching companion app version {}", version);
521518
this.newestCompatibleCompanionAppVersion = version;
522519
this.newestCompanionAppVersionSize = jsonObject.getAsJsonArray("assets").get(0)
@@ -525,7 +522,7 @@ private void loadNewestCompanionAppVersion() {
525522
}
526523
}
527524

528-
//return newest version if no matching version was found
525+
// Return newest version if no matching version was found
529526
String newestVersion = jsonArray.get(0).getAsJsonObject().get("tag_name").getAsString();
530527
TotalDebug.LOGGER.info("No matching companion app version found. Falling back to newest available {}", newestVersion);
531528
this.newestCompatibleCompanionAppVersion = newestVersion;
@@ -538,11 +535,6 @@ private void loadNewestCompanionAppVersion() {
538535
}
539536

540537
private static boolean areVersionsCompatible(String totalDebugVersion, String companionAppVersion) {
541-
if (totalDebugVersion.startsWith("v"))
542-
totalDebugVersion = totalDebugVersion.substring(1);
543-
if (companionAppVersion.startsWith("v"))
544-
companionAppVersion = companionAppVersion.substring(1);
545-
546538
String[] totalDebugVersionSplit = StringUtils.split(totalDebugVersion, '.');
547539
String[] companionAppVersionSplit = StringUtils.split(companionAppVersion, '.');
548540

0 commit comments

Comments
 (0)