Merge pull request #6396 from jmacxx/show_commit_hash

Store the build's commit hash in Jarfile manifest
This commit is contained in:
Alejandro García 2022-11-25 17:36:34 +02:00 committed by GitHub
commit a6293a64cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 6 deletions

View File

@ -237,6 +237,15 @@ configure(project(':common')) {
modules = ['javafx.graphics']
}
ext.getHash = {
def p1 = 'git rev-parse HEAD'.execute()
p1.waitFor()
return p1.text.substring(0,7)
}
jar.manifest.attributes(
"Implementation-Version": getHash())
dependencies {
implementation project(':proto')
annotationProcessor "org.projectlombok:lombok:$lombokVersion"

View File

@ -17,8 +17,12 @@
package bisq.common.app;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import lombok.extern.slf4j.Slf4j;
@ -136,6 +140,16 @@ public class Version {
'}');
}
public String readCommitHash() {
try {
String pth = getClass().getResource(getClass().getSimpleName() + ".class").toString();
String mnf = pth.substring(0, pth.lastIndexOf("!") + 1) + "/META-INF/MANIFEST.MF";
Attributes attr = new Manifest(new URL(mnf).openStream()).getMainAttributes();
return attr.getValue("Implementation-Version");
} catch (Exception ignored) { }
return "unknown";
}
public static final byte COMPENSATION_REQUEST = (byte) 0x01;
public static final byte REIMBURSEMENT_REQUEST = (byte) 0x01;
public static final byte PROPOSAL = (byte) 0x01;

View File

@ -29,7 +29,6 @@ import bisq.core.filter.FilterManager;
import bisq.core.network.p2p.inventory.messages.GetInventoryRequest;
import bisq.core.network.p2p.inventory.messages.GetInventoryResponse;
import bisq.core.network.p2p.inventory.model.InventoryItem;
import bisq.core.network.p2p.inventory.model.RequestInfo;
import bisq.network.p2p.network.Connection;
import bisq.network.p2p.network.MessageListener;
@ -151,7 +150,7 @@ public class GetInventoryRequestHandler implements MessageListener {
// node
inventory.put(InventoryItem.version, Version.VERSION);
inventory.put(InventoryItem.commitHash, RequestInfo.COMMIT_HASH);
inventory.put(InventoryItem.commitHash, new Version().readCommitHash());
inventory.put(InventoryItem.usedMemory, String.valueOf(Profiler.getUsedMemoryInBytes()));
inventory.put(InventoryItem.jvmStartTime, String.valueOf(ManagementFactory.getRuntimeMXBean().getStartTime()));

View File

@ -28,9 +28,6 @@ import org.jetbrains.annotations.Nullable;
@Getter
public class RequestInfo {
// Carries latest commit hash of feature changes (not latest commit as that is then the commit for editing that field)
public static final String COMMIT_HASH = "c07d47a8";
private final long requestStartTime;
@Setter
private long responseTime;

View File

@ -83,7 +83,7 @@ public abstract class HistoricalDataStoreService<T extends PersistableNetworkPay
"As our historical store is a newer version we add the data to our result map." :
"As the requester version is not older as our historical store we do not " +
"add the data to the result map.";
log.info("The requester had version {}. Our historical data store has version {}.\n{}",
log.trace("The requester had version {}. Our historical data store has version {}.\n{}",
requestersVersion, storeVersion, details);
return newVersion;
})