Display git commit id instead of TRUNK. Closes #1305.

This commit is contained in:
Antonin Delpeuch 2018-11-22 19:46:30 +00:00
parent d2147ec87c
commit 1d2888ba01
2 changed files with 13 additions and 6 deletions

View File

@ -35,6 +35,7 @@ package com.google.refine;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.ArrayList; import java.util.ArrayList;
@ -52,9 +53,12 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; 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.commands.Command;
import com.google.refine.importing.ImportingManager; import com.google.refine.importing.ImportingManager;
import com.google.refine.io.FileProjectManager; import com.google.refine.io.FileProjectManager;
import com.google.refine.util.ParsingUtilities;
import edu.mit.simile.butterfly.Butterfly; import edu.mit.simile.butterfly.Butterfly;
import edu.mit.simile.butterfly.ButterflyModule; import edu.mit.simile.butterfly.ButterflyModule;
@ -107,8 +111,16 @@ public class RefineServlet extends Butterfly {
VERSION = ASSIGNED_VERSION; VERSION = ASSIGNED_VERSION;
} }
if (REVISION.equals("$REVISION")) { if (REVISION.equals("$REVISION")) {
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"; REVISION = "TRUNK";
} }
}
FULL_VERSION = VERSION + " [" + REVISION + "]"; FULL_VERSION = VERSION + " [" + REVISION + "]";
FULLNAME += FULL_VERSION; FULLNAME += FULL_VERSION;

View File

@ -39,7 +39,6 @@ import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Method;
import java.net.BindException; import java.net.BindException;
import java.net.URI; import java.net.URI;
import java.util.ArrayList; import java.util.ArrayList;
@ -50,9 +49,6 @@ import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import org.apache.log4j.Level; import org.apache.log4j.Level;
import org.mortbay.jetty.Connector; import org.mortbay.jetty.Connector;
@ -66,7 +62,6 @@ import org.slf4j.LoggerFactory;
import com.codeberry.jdatapath.DataPath; import com.codeberry.jdatapath.DataPath;
import com.codeberry.jdatapath.JDataPathSystem; import com.codeberry.jdatapath.JDataPathSystem;
import com.google.util.threads.ThreadPoolExecutorAdapter; import com.google.util.threads.ThreadPoolExecutorAdapter;
/** /**