Skip to content
Snippets Groups Projects
Commit 56dbb483 authored by Tom Fischer's avatar Tom Fischer
Browse files

Merge pull request #439 from bilke/git-commit-info

Git commit infos on Doxygen front page and Data Explorer About dialog
parents 700a881f bd75f3ce
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@
GET_SOURCE_FILES(SOURCES)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/GitSHA1.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/GitSHA1.cpp" @ONLY)
LIST(APPEND SOURCES "${CMAKE_CURRENT_BINARY_DIR}/GitSHA1.cpp" GitSHA1.h)
# Create the library
ADD_LIBRARY( BaseLib STATIC ${SOURCES})
......@@ -17,4 +20,4 @@ TARGET_LINK_LIBRARIES( BaseLib
IF(WIN32)
TARGET_LINK_LIBRARIES( BaseLib WinMM )
ENDIF()
\ No newline at end of file
ENDIF()
#include <stdio.h>
#include "GitSHA1.h"
#define GIT_SHA1 "@GIT_SHA1@"
const char g_GIT_SHA1[] = GIT_SHA1;
#define GIT_SHA1_SHORT "@GIT_SHA1_SHORT@"
const char g_GIT_SHA1_SHORT[] = GIT_SHA1_SHORT;
void dummy()
{
printf(g_GIT_SHA1);
printf(g_GIT_SHA1_SHORT);
}
extern const char g_GIT_SHA1[];
extern const char g_GIT_SHA1_SHORT[];
......@@ -14,7 +14,7 @@ PROJECT( OGS-6 )
SET (OGS_VERSION_MAJOR 6)
SET (OGS_VERSION_MINOR 0)
SET (OGS_VERSION_PATCH "0 Beta")
SET (OGS_RELEASE_PERSONS "LB/TF/KR")
SET (OGS_RELEASE_PERSONS "Core developers")
SET (OGS_VERSION "${OGS_VERSION_MAJOR}.${OGS_VERSION_MINOR}.${OGS_VERSION_PATCH}")
SET (OGS_VERSION_AND_PERSONS "${OGS_VERSION} (${OGS_RELEASE_PERSONS})")
SET (OGS_DATE "2012-08-20")
......
......@@ -18,6 +18,8 @@
// ThirdParty/logog
#include "logog/include/logog.hpp"
// BaseLib
#include "GitSHA1.h"
#include "FileTools.h"
// models
......@@ -693,7 +695,7 @@ void MainWindow::loadFile(ImportFileType::type t, const QString &fileName)
settings.setValue("lastOpenedTetgenFileDirectory", QFileInfo(fileName).absolutePath());
QString element_fname(fi.path() + "/" + fi.completeBaseName() + ".ele");
if (!fileName.isEmpty())
if (!fileName.isEmpty())
{
FileIO::TetGenInterface tetgen;
MeshLib::Mesh* mesh (tetgen.readTetGenMesh(fileName.toStdString(), element_fname.toStdString()));
......@@ -748,21 +750,12 @@ void MainWindow::about()
{
QString about("<a href='http://www.opengeosys.org'>http://www.opengeosys.org</a><br /><br />");
QString ogsVersion = QString(OGS_VERSION_AND_PERSONS);
about.append(tr("Built on %1<br />OGS Version: %2<br /><br />").arg(
QDate::currentDate().toString(Qt::ISODate)).arg(ogsVersion));
#ifdef OGS_BUILD_INFO
#ifdef SVN_REVISION
about.append(QString("Svn commit: %1<br />").arg(SVN_REVISION));
#endif
#ifdef GIT_COMMIT_INFO
QString gitCommit = QString(GIT_COMMIT_INFO);
about.append(QString("Git commit: %1<br />").arg(gitCommit.mid(7)));
#endif // GIT_COMMIT_INFO
#ifdef GIT_BRANCH_INFO
QString gitBranch = QString(GIT_BRANCH_INFO);
about.append(QString("Git branch: %1<br />").arg(gitBranch.mid(2)));
#endif // GIT_BRANCH_INFO
#endif // OGS_BUILD_INFO
about.append(QString("Version: %1<br /><br />").arg(ogsVersion));
about.append(QString("Git commit: <a href='https://github.com/ufz/ogs/commit/%1'>%1</a><br />")
.arg(QString(g_GIT_SHA1_SHORT)));
about.append(QString("Built date: %1<br />").arg(QDate::currentDate().toString(Qt::ISODate)));
QMessageBox::about(this, "About OpenGeoSys 6", about);
}
......
......@@ -8,10 +8,15 @@ INCLUDE(UseBackportedModules)
INCLUDE(OptionRequires)
INCLUDE(CppcheckTargets)
INCLUDE(GetCompilerInfoString)
INCLUDE(ProcessorCount)
ProcessorCount(NUM_PROCESSORS)
SET(NUM_PROCESSORS ${NUM_PROCESSORS} CACHE STRING "Processor count")
INCLUDE(GetGitRevisionDescription)
GET_GIT_HEAD_REVISION(GIT_REFSPEC GIT_SHA1)
STRING(SUBSTRING ${GIT_SHA1} 0 8 GIT_SHA1_SHORT)
# Suppress warning on setting policies
CMAKE_POLICY(SET CMP0011 OLD)
......
......@@ -3,16 +3,16 @@
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additonal arguments to git describe> ...])
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additonal arguments to git describe> ...])
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additonal arguments to git describe> ...])
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
......@@ -40,21 +40,40 @@ set(__get_git_revision_description YES)
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_DIR "${CMAKE_SOURCE_DIR}/.git")
if(NOT EXISTS "${GIT_DIR}")
# not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" "${GIT_DATA}/grabRef.cmake" @ONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
......@@ -67,11 +86,11 @@ function(git_describe _var)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
......@@ -85,10 +104,17 @@ function(git_describe _var)
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND "${GIT_EXECUTABLE}" describe ${hash} ${ARGN}
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE res
OUTPUT_VARIABLE out
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
......
#
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
......@@ -22,7 +22,7 @@ if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
elseif(EXISTS "@GIT_DIR@/logs/${HEAD_REF}")
configure_file("@GIT_DIR@/logs/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
set(HEAD_HASH "${HEAD_REF}")
......@@ -33,6 +33,6 @@ else()
endif()
if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()
......@@ -32,13 +32,13 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.
PROJECT_NAME = "OGS"
PROJECT_NAME = "OGS ${OGS_VERSION}"
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = ${OGS_VERSION}
PROJECT_NUMBER = ${GIT_SHA1_SHORT}
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment