working-directory: /home/nominatim
if: matrix.flavour == 'centos'
+ - name: Print version
+ run: nominatim --version
+ working-directory: /home/nominatim/nominatim-project
+
- name: Import
run: nominatim import --osm-file ../test.pbf
working-directory: /home/nominatim/nominatim-project
add_definitions(-DNOMINATIM_VERSION="${NOMINATIM_VERSION}")
+# Setting GIT_HASH
+find_package(Git)
+if (GIT_FOUND)
+ execute_process(
+ COMMAND "${GIT_EXECUTABLE}" log -1 --format=%h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
+ OUTPUT_VARIABLE GIT_HASH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+endif()
#-----------------------------------------------------------------------------
# Configuration
os.environ['NOMINATIM_NOMINATIM_TOOL'] = os.path.abspath(__file__)
from nominatim import cli
+from nominatim import version
+
+version.GIT_COMMIT_HASH = '@GIT_HASH@'
exit(cli.nominatim(module_dir='@NOMINATIM_LIBDIR@/module',
osm2pgsql_path='@NOMINATIM_LIBDIR@/osm2pgsql',
os.environ['NOMINATIM_NOMINATIM_TOOL'] = os.path.abspath(__file__)
from nominatim import cli
+from nominatim import version
+
+version.GIT_COMMIT_HASH = '@GIT_HASH@'
exit(cli.nominatim(module_dir='@CMAKE_BINARY_DIR@/module',
osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql',
dest='subcommand')
# Global arguments that only work if no sub-command given
- self.parser.add_argument('--version', action='version',
- version=CommandlineParser.nominatim_version_text(),
+ self.parser.add_argument('--version', action='store_true',
help='Print Nominatim version and exit')
# Arguments added to every sub-command
def nominatim_version_text():
""" Program name and version number as string
"""
- return "Nominatim version %s.%s.%s.%s\n" % version.NOMINATIM_VERSION
+ text = 'Nominatim version %s.%s.%s.%s' % version.NOMINATIM_VERSION
+ if version.GIT_COMMIT_HASH is not None:
+ text += ' (%s)' % version.GIT_COMMIT_HASH
+ return text
def add_subcommand(self, name, cmd):
""" Add a subcommand to the parser. The subcommand must be a class
except SystemExit:
return 1
+ if args.version:
+ print(CommandlineParser.nominatim_version_text())
+ return 0
+
if args.subcommand is None:
self.parser.print_help()
return 1
POSTGRESQL_REQUIRED_VERSION = (9, 5)
POSTGIS_REQUIRED_VERSION = (2, 2)
+
+# Cmake sets a variabe @GIT_HASH@ by executing 'git --log'. It is not run
+# on every execution of 'make'.
+# cmake/tool-installed.tmpl is used to build the binary 'nominatim'. Inside
+# there is a call to set the variable value below.
+GIT_COMMIT_HASH = None
def test_cli_version(cli_call, capsys):
""" Running nominatim tool --version prints a version string.
"""
- assert cli_call('--version') == 1
+ assert cli_call('--version') == 0
captured = capsys.readouterr()
assert captured.out.startswith('Nominatim version')