From 98c655d9a00fabd2f456e9b3f6df331b235aebb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kr=C3=BChlmann?= Date: Thu, 1 Jan 2026 17:14:26 +0100 Subject: [PATCH] Remove git versioning --- .../imgfloat/service/VersionService.java | 56 ------------------- 1 file changed, 56 deletions(-) diff --git a/src/main/java/dev/kruhlmann/imgfloat/service/VersionService.java b/src/main/java/dev/kruhlmann/imgfloat/service/VersionService.java index 08b0fb7..dd47c80 100644 --- a/src/main/java/dev/kruhlmann/imgfloat/service/VersionService.java +++ b/src/main/java/dev/kruhlmann/imgfloat/service/VersionService.java @@ -4,9 +4,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; -import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStreamReader; @Component public class VersionService { @@ -28,21 +26,11 @@ public class VersionService { } private String resolveVersion() { - String manifestVersion = getClass().getPackage().getImplementationVersion(); - if (manifestVersion != null && !manifestVersion.isBlank()) { - return manifestVersion; - } - String pomVersion = getPomVersion(); if (pomVersion != null && !pomVersion.isBlank()) { return pomVersion; } - String gitDescribeVersion = getGitVersionString(); - if (gitDescribeVersion != null) { - return "git-" + gitDescribeVersion; - } - return "unknown"; } @@ -52,7 +40,6 @@ public class VersionService { } String normalized = baseVersion.trim(); - normalized = normalized.replaceFirst("^git-", ""); normalized = normalized.replaceFirst("(?i)^v", ""); normalized = normalized.replaceFirst("-SNAPSHOT$", ""); if (normalized.isBlank()) { @@ -77,47 +64,4 @@ public class VersionService { } return null; } - - private String getGitVersionString() { - try { - Process check = new ProcessBuilder("git", "--version") - .redirectErrorStream(true) - .start(); - - if (check.waitFor() != 0) { - LOG.info("git not found on PATH, skipping git version detection"); - return null; - } - } catch (Exception e) { - LOG.info("git not found on PATH, skipping git version detection"); - return null; - } - - Process process = null; - try { - process = new ProcessBuilder("git", "describe", "--tags", "--always") - .redirectErrorStream(true) - .start(); - try (BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()))) { - String result = reader.readLine(); - int exitCode = process.waitFor(); - if (exitCode == 0 && result != null && !result.isBlank()) { - return result.trim(); - } - LOG.warn("git describe returned exit code {} with output: {}", exitCode, result); - } - } catch (IOException e) { - LOG.warn("Unable to determine git version using git describe", e); - if (process != null) { - process.destroyForcibly(); - } - } catch (InterruptedException e) { - LOG.warn("Interrupted while determining git version", e); - if (process != null) { - process.destroyForcibly(); - } - Thread.currentThread().interrupt(); - } - return null; - } }