Skip to content

Commit

Permalink
Add a commit date to the About version info (#5610)
Browse files Browse the repository at this point in the history
* Add a commit date to the version info

* remove this force check for vagrant marker file

was causing infinite loop in make clean
not sure why, but also don't think this step is useful anymore

* remove FORCE reference

* update test expectation

* copyright
  • Loading branch information
brianhatchl authored Mar 24, 2023
1 parent 01ea8dc commit cbbaa64
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 26 deletions.
6 changes: 5 additions & 1 deletion HOOT_VERSION_GEN
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if test -f version
then
VN=$(cat version) || VN="$DEF_VER"
elif test "$HAS_GIT" = "true" &&
VD=$(git show -s --format=%ci | awk '{print $1;}') &&
VN=$(git describe --match "v[0-9]*" --abbrev=7 --tags HEAD 2>/dev/null | sed -e s/-/_/g) &&
case "$VN" in
*$LF*) (exit 1) ;;
Expand All @@ -34,7 +35,7 @@ else
VN="$DEF_VER"
fi

# VN is the full version number. E.g. 0.1.0 if it is a tag. 0.1.0-2-deadbeef
# VN is the full version number. E.g. 0.1.0 if it is a tag. 0.1.0-2-deadbeef
# if it is not a tagged version
VN=$(expr "$VN" : v*'\(.*\)')

Expand All @@ -54,10 +55,13 @@ fi
# If the version has changed, then rewrite the version header file.
test "$VN" = "$VC" || {
echo "HOOT_VERSION = $VN" >$HVF
echo "HOOT_DATE = $VD" >>$HVF
echo "HOOT_BUILT_BY = $(whoami)" >>$HVF

cat hoot-core/src/main/cpp/hoot/core/info/VersionDefines.h.in | \
sed -e "s/@HOOT_VERSION@/$VN/g" | \
sed -e "s/@HOOT_REVISION@/$HOOT_REVISION/g" | \
sed -e "s/@HOOT_DATE@/$VD/g" | \
sed -e "s/@HOOT_BUILT_BY@/$(whoami)/g" > \
hoot-core/src/main/cpp/hoot/core/info/VersionDefines.h
}
Expand Down
8 changes: 1 addition & 7 deletions Makefile.hoot
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,7 @@ else
echo "UI tests must specify both --with-services and --with-uitests."
endif

FORCE: vagrant

HOOT_VERSION_FILE: FORCE
HOOT_VERSION_FILE:
$(SHELL_PATH) ./HOOT_VERSION_GEN;
-include HOOT_VERSION_FILE

Expand Down Expand Up @@ -540,7 +538,3 @@ eclipse:
ifeq ($(BUILD_SERVICES),services)
scripts/maven/mvn-build $(MVN_QUIET) eclipse
endif

vagrant:
# Check the Vagrant.marker file data to see if provisioning needs to run
if [ -f Vagrant.marker ]; then if [ Vagrant.marker -ot VagrantProvision.sh ]; then echo; echo; echo "New dependencies have been added to Vagrant!"; echo "Please exit the vm and run 'vagrant provision' or"; echo "run 'touch Vagrant.marker' and re-run 'make' to continue."; echo; echo; false; fi fi
4 changes: 2 additions & 2 deletions hoot-core/src/main/cpp/hoot/core/cmd/VersionCmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015-2023 Maxar (http://www.maxar.com/)
*/

// Boost
Expand Down Expand Up @@ -106,7 +106,7 @@ class VersionCmd : public BaseCommand
if (!args.empty())
throw HootException(QString("%1 takes no parameters.").arg(getName()));

cout << Version::getFullVersion() << " Built By: " << Version::getBuiltBy() << endl;
cout << Version::getFullVersion() << " " << Version::getDate() << " built by " << Version::getBuiltBy() << endl;
LOG_DEBUG("GEOS Version:\t" << geosversion());
LOG_DEBUG("GDAL Version:\t" << GDALVersionInfo("RELEASE_NAME"));
LOG_DEBUG("GLPK Version:\t" << glp_version());
Expand Down
7 changes: 6 additions & 1 deletion hoot-core/src/main/cpp/hoot/core/info/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2017, 2018, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015-2023 Maxar (http://www.maxar.com/)
*/

#include "Version.h"
Expand Down Expand Up @@ -53,4 +53,9 @@ const char* Version::getVersion()
return HOOT_VERSION;
}

const char* Version::getDate()
{
return HOOT_DATE;
}

}
4 changes: 3 additions & 1 deletion hoot-core/src/main/cpp/hoot/core/info/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2017, 2018, 2019, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015-2023 Maxar (http://www.maxar.com/)
*/

#ifndef VERSION_H
Expand All @@ -42,6 +42,8 @@ class Version
static const char* getRevision();

static const char* getVersion();

static const char* getDate();
};
}

Expand Down
3 changes: 3 additions & 0 deletions hoot-core/src/main/cpp/hoot/core/info/VersionDefines.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#ifndef HOOT_FULL_VERSION
# define HOOT_FULL_VERSION "Hootenanny @HOOT_VERSION@"
#endif
#ifndef HOOT_DATE
# define HOOT_DATE "@HOOT_DATE@"
#endif
#ifndef HOOT_BUILT_BY
# define HOOT_BUILT_BY "@HOOT_BUILT_BY@"
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015-2023 Maxar (http://www.maxar.com/)
*/
package hoot.services.controllers.info;

Expand Down Expand Up @@ -72,6 +72,7 @@ public VersionInfo getServicesVersionInfo() {
versionInfo = new VersionInfo();
versionInfo.setName(buildInfo.getProperty("name"));
versionInfo.setVersion(buildInfo.getProperty("version"));
versionInfo.setDate(buildInfo.getProperty("date"));
versionInfo.setBuiltBy(buildInfo.getProperty("user"));
}
catch (Exception e) {
Expand Down Expand Up @@ -100,9 +101,10 @@ public VersionInfo getCoreVersionInfo() {
String versionStr = this.getCoreInfo(false);
String[] versionInfoParts = versionStr.split(" ");
versionInfo = new VersionInfo();
versionInfo.setName("Hootenanny Core");
versionInfo.setName("Core");
versionInfo.setVersion(versionInfoParts[1]);
versionInfo.setBuiltBy(versionInfoParts[4]);
versionInfo.setDate(versionInfoParts[2]);
versionInfo.setBuiltBy(versionInfoParts[5]);
}
catch (Exception e) {
String msg = "Error retrieving core version info! Cause: " + e.getMessage();
Expand Down Expand Up @@ -161,6 +163,7 @@ private static Properties getBuildInfo() {
buildInfo = new Properties();
buildInfo.setProperty("name", "unknown");
buildInfo.setProperty("version", "unknown");
buildInfo.setProperty("date", "unknown");
buildInfo.setProperty("user", "unknown");
}

Expand All @@ -174,7 +177,7 @@ private static String parseCoreVersionOutOf(String text, boolean withDetails) {
String[] lines = text.split("\\r?\\n");
for (int i = 0; i < lines.length; i++) {
String line = lines[i].trim();
if (line.startsWith("Hootenanny") && line.contains("Built By:")) {
if (line.startsWith("Hootenanny") && line.contains("built by")) {
coreVersion = line;
if (withDetails) {
if ((i + 1) < lines.length) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2016, 2017, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2016-2023 Maxar (http://www.maxar.com/)
*/
package hoot.services.controllers.info;

Expand All @@ -33,6 +33,7 @@
public class VersionInfo {
private String name;
private String version;
private String date;
private String builtBy;

public VersionInfo() {
Expand All @@ -54,6 +55,14 @@ public void setVersion(String version) {
this.version = version;
}

public String getDate() {
return date;
}

public void setDate(String date) {
this.date = date;
}

public String getBuiltBy() {
return builtBy;
}
Expand All @@ -66,6 +75,7 @@ public void setBuiltBy(String builtBy) {
public String toString() {
return "Name: " + name + System.lineSeparator() +
"Version: " + version + System.lineSeparator() +
"Date: " + date + System.lineSeparator() +
"Built By: " + builtBy;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This will properly maintain the copyright information. Maxar
* copyrights will be updated automatically.
*
* @copyright Copyright (C) 2015, 2016, 2017, 2021 Maxar (http://www.maxar.com/)
* @copyright Copyright (C) 2015-2023 Maxar (http://www.maxar.com/)
*/
package hoot.services.controllers.info;

Expand Down Expand Up @@ -132,20 +132,20 @@ public void testCoreVersionParser() throws Exception {
privateMethod.setAccessible(true);

String returnValue = (String) privateMethod.invoke(aboutResource,
"Hootenanny 0.2.23_1036_ga13f8a9_dirty Built By: vagrant", false);
assertEquals("Hootenanny 0.2.23_1036_ga13f8a9_dirty Built By: vagrant", returnValue);
"Hootenanny 0.2.23_1036_ga13f8a9_dirty built by vagrant", false);
assertEquals("Hootenanny 0.2.23_1036_ga13f8a9_dirty built by vagrant", returnValue);

returnValue = (String) privateMethod.invoke(aboutResource,
"This is just a line" + System.lineSeparator() +
"Hootenanny 0.2.23_1036_ga13f8a9_dirty Built By: vagrant", true);
assertEquals("Hootenanny 0.2.23_1036_ga13f8a9_dirty Built By: vagrant", returnValue);
"Hootenanny 0.2.23_1036_ga13f8a9_dirty built by vagrant", true);
assertEquals("Hootenanny 0.2.23_1036_ga13f8a9_dirty built by vagrant", returnValue);

returnValue = (String) privateMethod.invoke(aboutResource,
"14:27:08.974 WARN ...rc/main/cpp/hoot/core/Hoot.cpp( 135) " + System.lineSeparator() + " "
+ "Cannot load library HootHadoop: (libhdfs.so.0: cannot open shared object file: No such file or directory)" + System.lineSeparator() +
"Hootenanny 0.2.23_1036_ga13f8a9_dirty Built By: vagrant",
"Hootenanny 0.2.23_1036_ga13f8a9_dirty built by vagrant",
true);
assertEquals("Hootenanny 0.2.23_1036_ga13f8a9_dirty Built By: vagrant", returnValue);
assertEquals("Hootenanny 0.2.23_1036_ga13f8a9_dirty built by vagrant", returnValue);

returnValue = (String) privateMethod.invoke(aboutResource,
"14:27:08.974 WARN ...rc/main/cpp/hoot/core/Hoot.cpp( 135) " + System.lineSeparator() + " "
Expand Down
7 changes: 5 additions & 2 deletions scripts/GenerateBuildInfoFiles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
HOOT_VERSION=`cat ../HOOT_VERSION_FILE | grep "HOOT_VERSION" | awk '{print $3;}'`
#echo "HOOT_VERSION: " $HOOT_VERSION
#echo "USER: " $USER
HOOT_VERSION_DATE=`cat ../HOOT_VERSION_FILE | grep "HOOT_DATE" | awk '{print $3;}'`
HOOT_BUILT_BY=`cat ../HOOT_VERSION_FILE | grep "HOOT_BUILT_BY" | awk '{print $3;}'`

SERVICES_BUILD_INFO_FILE=./src/main/resources/build.info
echo "name=Hootenanny Web Services" > $SERVICES_BUILD_INFO_FILE
echo "name=Services" > $SERVICES_BUILD_INFO_FILE
echo "version="$HOOT_VERSION >> $SERVICES_BUILD_INFO_FILE
echo "user="$USER >> $SERVICES_BUILD_INFO_FILE
echo "date="$HOOT_VERSION_DATE >> $SERVICES_BUILD_INFO_FILE
echo "user="$HOOT_BUILT_BY >> $SERVICES_BUILD_INFO_FILE

0 comments on commit cbbaa64

Please sign in to comment.