Skip to content

Commit

Permalink
Show git SHA for command line parameter --version
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj authored Feb 27, 2024
1 parent 672fbe1 commit a0ecdf4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ApplicationExeCode/RiaMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ RiaApplication* createApplication( int& argc, char* argv[] )
{
for ( int i = 1; i < argc; ++i )
{
if ( !qstrcmp( argv[i], "--console" ) || !qstrcmp( argv[i], "--unittest" ) || !qstrcmp( argv[i], "--version" ) )
if ( !qstrcmp( argv[i], "--console" ) || !qstrcmp( argv[i], "--unittest" ) )
{
#ifdef ENABLE_GRPC
return new RiaGrpcConsoleApplication( argc, argv );
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/Adm/RiaVersionInfo.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@
#define RESINSIGHT_OCTAVE_VERSION "@OCTAVE_VERSION_STRING@"

#define RESINSIGHT_PYTHON_VERSION "@Python3_VERSION@"

#define RESINSIGHT_GIT_HASH "@RESINSIGHT_GIT_HASH@"
1 change: 1 addition & 0 deletions ApplicationLibCode/Application/RiaConsoleApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ RiaApplication::ApplicationStatus RiaConsoleApplication::handleArguments( gsl::n
if ( progOpt->option( "version" ) )
{
QString text = QString( STRPRODUCTVER ) + "\n";
text += "SHA " + QString( RESINSIGHT_GIT_HASH ) + "\n";

showFormattedTextInMessageBoxOrConsole( text );

Expand Down
10 changes: 10 additions & 0 deletions ApplicationLibCode/Application/RiaGuiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,16 @@ RiaApplication::ApplicationStatus RiaGuiApplication::handleArguments( gsl::not_n
return RiaApplication::ApplicationStatus::EXIT_COMPLETED;
}

if ( progOpt->option( "version" ) )
{
QString text = QString( STRPRODUCTVER ) + "\n";
text += "SHA " + QString( RESINSIGHT_GIT_HASH ) + "\n";

showFormattedTextInMessageBoxOrConsole( text );

return RiaApplication::ApplicationStatus::EXIT_COMPLETED;
}

// Code generation
// -----------------
if ( cvf::Option o = progOpt->option( "generate" ) )
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,12 @@ set(CMAKE_CXX_COMPILER_LAUNCHER ${TEMP_CMAKE_CXX_COMPILER_LAUNCHER})
# ##############################################################################
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
execute_process(
COMMAND git log -1 --pretty=format:%h
OUTPUT_VARIABLE RESINSIGHT_GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET
)

# Update submodules as needed
option(RESINSIGHT_UPDATE_SUBMODULES "Check submodules during build" ON)
mark_as_advanced(RESINSIGHT_UPDATE_SUBMODULES)
Expand Down

0 comments on commit a0ecdf4

Please sign in to comment.