Skip to content

Commit

Permalink
print git sha1 (#943)
Browse files Browse the repository at this point in the history
output:
----------------------------------------------------------------
[Pre Antares][INFO 08-10-2024 10:41:30]  Running Antares Xpansion ... 
[Pre Antares][INFO 08-10-2024 10:41:30]  user: bari
[Pre Antares][INFO 08-10-2024 10:41:30]  hostname: Desk
[Pre Antares][INFO 08-10-2024 10:41:30]  Xpansion version: 1.3.2
[Pre Antares][INFO 08-10-2024 10:41:30]  Xpansion revision: 9629a33
[Pre Antares][INFO 08-10-2024 10:41:30]  antares simulator version: 9.2
----------------------------------------------------------------
  • Loading branch information
a-zakir authored Oct 8, 2024
1 parent 96751d9 commit 58c9a15
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ if (ANTARES_XPANSION_RC)
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}-rc${ANTARES_XPANSION_RC}")
endif ()

# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

#version file to define Xpansion and Antares-simulator versions
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/python/antares_xpansion/__version__.py.in ${CMAKE_CURRENT_SOURCE_DIR}/src/python/antares_xpansion/__version__.py)
include(CPack)
1 change: 1 addition & 0 deletions src/python/antares_xpansion/__version__.py.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__version__ = "${CMAKE_PROJECT_VERSION}"
__revision__ = "${GIT_HASH}"
__antares_simulator_version__ = "${ANTARES_VERSION}"
6 changes: 5 additions & 1 deletion src/python/antares_xpansion/input_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
from typing import List

from antares_xpansion.__version__ import __version__, __antares_simulator_version__
from antares_xpansion.__version__ import __version__, __revision__, __antares_simulator_version__
from antares_xpansion.launcher_options_default_value import LauncherOptionsDefaultValues
from antares_xpansion.launcher_options_keys import LauncherOptionsKeys
from antares_xpansion.xpansionConfig import InputParameters
Expand Down Expand Up @@ -62,6 +62,10 @@ def _initialize_parser(self):
action='version',
version=__version__,
help='show antares-xpansion version and exit ')
self.parser.add_argument("--revision",
action='version',
version=__revision__,
help='show the latest abbreviated commit hash ')
self.parser.add_argument("--antares-version",
action='version',
version=__antares_simulator_version__,
Expand Down
5 changes: 3 additions & 2 deletions src/python/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from antares_xpansion.xpansionConfig import XpansionConfig
from antares_xpansion.driver import XpansionDriver
from antares_xpansion.config_loader import ConfigLoader
from antares_xpansion.__version__ import __version__, __antares_simulator_version__
from antares_xpansion.__version__ import __version__,__revision__, __antares_simulator_version__
from antares_xpansion.logger import get_logger, step_logger
from antares_xpansion.log_utils import LogUtils
import os
Expand All @@ -35,8 +35,9 @@
logger.info(f"user: {LogUtils.user_name()}", extra=step_info)
logger.info(f"hostname: {LogUtils.host_name()}", extra=step_info)
logger.info(f"Xpansion version: {__version__}", extra=step_info)
logger.info(f"Xpansion revision: {__revision__}", extra=step_info)
logger.info(
f"antares simulator version: {__antares_simulator_version__}", extra=step_info)
f"Antares Simulator version: {__antares_simulator_version__}", extra=step_info)
logger.info(
"----------------------------------------------------------------", extra=simple_message)

Expand Down

0 comments on commit 58c9a15

Please sign in to comment.