From 1d2888ba0198a78f2ca6e763c07e120ea70cb5b7 Mon Sep 17 00:00:00 2001 From: Antonin Delpeuch Date: Thu, 22 Nov 2018 19:46:30 +0000 Subject: [PATCH] Display git commit id instead of TRUNK. Closes #1305. --- main/src/com/google/refine/RefineServlet.java | 14 +++++++++++++- server/src/com/google/refine/Refine.java | 5 ----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/main/src/com/google/refine/RefineServlet.java b/main/src/com/google/refine/RefineServlet.java index 5597aab83..4297edb2a 100644 --- a/main/src/com/google/refine/RefineServlet.java +++ b/main/src/com/google/refine/RefineServlet.java @@ -35,6 +35,7 @@ package com.google.refine; import java.io.File; import java.io.IOException; +import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URLConnection; import java.util.ArrayList; @@ -52,9 +53,12 @@ import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.refine.commands.Command; import com.google.refine.importing.ImportingManager; import com.google.refine.io.FileProjectManager; +import com.google.refine.util.ParsingUtilities; import edu.mit.simile.butterfly.Butterfly; import edu.mit.simile.butterfly.ButterflyModule; @@ -107,7 +111,15 @@ public class RefineServlet extends Butterfly { VERSION = ASSIGNED_VERSION; } if (REVISION.equals("$REVISION")) { - REVISION = "TRUNK"; + ClassLoader classLoader = getClass().getClassLoader(); + InputStream gitStats = classLoader.getResourceAsStream("git.properties"); + ObjectMapper mapper = new ObjectMapper(); + try { + ObjectNode parsedGit = mapper.readValue(gitStats, ObjectNode.class); + REVISION = parsedGit.get("git.commit.id.abbrev").asText("TRUNK"); + } catch (IOException e) { + REVISION = "TRUNK"; + } } FULL_VERSION = VERSION + " [" + REVISION + "]"; diff --git a/server/src/com/google/refine/Refine.java b/server/src/com/google/refine/Refine.java index 7e6e32a9a..e0183fe85 100644 --- a/server/src/com/google/refine/Refine.java +++ b/server/src/com/google/refine/Refine.java @@ -39,7 +39,6 @@ import java.awt.event.ActionListener; import java.io.File; import java.io.FileFilter; import java.io.IOException; -import java.lang.reflect.Method; import java.net.BindException; import java.net.URI; import java.util.ArrayList; @@ -50,9 +49,6 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import javax.swing.JFrame; -import javax.swing.JMenu; -import javax.swing.JMenuBar; -import javax.swing.JMenuItem; import org.apache.log4j.Level; import org.mortbay.jetty.Connector; @@ -66,7 +62,6 @@ import org.slf4j.LoggerFactory; import com.codeberry.jdatapath.DataPath; import com.codeberry.jdatapath.JDataPathSystem; - import com.google.util.threads.ThreadPoolExecutorAdapter; /**