Merge pull request #1856 from OpenRefine/issue1305

Display git commit id instead of "TRUNK"
This commit is contained in:
Antonin Delpeuch 2018-11-23 10:41:07 +00:00 committed by GitHub
commit 998a5423db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 6 deletions

View File

@ -262,6 +262,32 @@
</filesets> </filesets>
</configuration> </configuration>
</plugin> </plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.4</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<prefix>git</prefix>
<verbose>false</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<format>json</format>
<gitDescribe>
<skip>false</skip>
<always>false</always>
<dirty>-dirty</dirty>
</gitDescribe>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>

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,7 +111,15 @@ public class RefineServlet extends Butterfly {
VERSION = ASSIGNED_VERSION; VERSION = ASSIGNED_VERSION;
} }
if (REVISION.equals("$REVISION")) { if (REVISION.equals("$REVISION")) {
REVISION = "TRUNK"; ClassLoader classLoader = getClass().getClassLoader();
try {
InputStream gitStats = classLoader.getResourceAsStream("git.properties");
ObjectMapper mapper = new ObjectMapper();
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 + "]"; FULL_VERSION = VERSION + " [" + REVISION + "]";

View File

@ -46,6 +46,11 @@
<exclude name="WEB-INF/lib/icu4j*.jar"/> <exclude name="WEB-INF/lib/icu4j*.jar"/>
</fileset> </fileset>
</copy> </copy>
<copy todir="${built.webapp.dir}">
<fileset dir="${webapp.dir}">
<include name="**/*.properties"/>
</fileset>
</copy>
<copy todir="${built.webapp.dir}/WEB-INF/lib/"> <copy todir="${built.webapp.dir}/WEB-INF/lib/">
<fileset dir="${webapp.target}"> <fileset dir="${webapp.target}">
<include name="openrefine-main.jar" /> <include name="openrefine-main.jar" />

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;
/** /**