mirror of
https://github.com/imgfloat/server.git
synced 2026-02-05 03:39:26 +00:00
Add manifest version
This commit is contained in:
@@ -22,6 +22,20 @@ public class GitVersionService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String resolveVersion() {
|
private String resolveVersion() {
|
||||||
|
String gitDescribeVersion = tryGitDescribe();
|
||||||
|
if (gitDescribeVersion != null) {
|
||||||
|
return gitDescribeVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
String manifestVersion = getClass().getPackage().getImplementationVersion();
|
||||||
|
if (manifestVersion != null && !manifestVersion.isBlank()) {
|
||||||
|
return manifestVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String tryGitDescribe() {
|
||||||
Process process = null;
|
Process process = null;
|
||||||
try {
|
try {
|
||||||
process = new ProcessBuilder("git", "describe", "--tags", "--always")
|
process = new ProcessBuilder("git", "describe", "--tags", "--always")
|
||||||
@@ -36,7 +50,7 @@ public class GitVersionService {
|
|||||||
LOG.warn("git describe returned exit code {} with output: {}", exitCode, result);
|
LOG.warn("git describe returned exit code {} with output: {}", exitCode, result);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.warn("Unable to determine git version", e);
|
LOG.warn("Unable to determine git version using git describe", e);
|
||||||
if (process != null) {
|
if (process != null) {
|
||||||
process.destroyForcibly();
|
process.destroyForcibly();
|
||||||
}
|
}
|
||||||
@@ -47,6 +61,6 @@ public class GitVersionService {
|
|||||||
}
|
}
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
return "unknown";
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user