Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package com.alibaba.higress.console.service;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
Expand Down Expand Up @@ -41,12 +43,7 @@ public class SystemServiceImpl implements SystemService {
static {
String commitId = null;
try {
Properties properties = new Properties();
properties.load(SystemServiceImpl.class.getResourceAsStream("/git.properties"));
commitId = properties.getProperty("git.commit.id");
if (commitId != null && commitId.length() > 7) {
commitId = commitId.substring(0, 7);
}
commitId = loadGitCommitId();
} catch (Exception ex) {
log.error("Failed to load git properties.", ex);
}
Expand Down Expand Up @@ -90,4 +87,20 @@ public void initialize() {
public SystemInfo getSystemInfo() {
return new SystemInfo(fullVersion, capabilities);
}

private static String loadGitCommitId() throws IOException {
try (InputStream input = SystemServiceImpl.class.getResourceAsStream("/git.properties")) {
if (input == null) {
log.warn("git.properties not found.");
return null;
}
Properties properties = new Properties();
properties.load(input);
String commitId = properties.getProperty("git.commit.id");
if (commitId != null && commitId.length() > 7) {
commitId = commitId.substring(0, 7);
}
return commitId;
}
}
}