Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show git SHA for command line parameter --version #11229

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading