Skip to content

Commit d25f94e

Browse files
authored
Merge branch 'master' into deps/bump-requests
2 parents 3e97782 + cd4524c commit d25f94e

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

reframe/frontend/cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def main():
285285
envvar='RFM_STAGE_DIR', configvar='systems/stagedir'
286286
)
287287
output_options.add_argument(
288-
'--save-log-files', action='store_true', default=False,
288+
'--save-log-files', action='store_true',
289289
help='Save ReFrame log files to the output directory',
290290
envvar='RFM_SAVE_LOG_FILES', configvar='general/save_log_files'
291291
)
@@ -474,12 +474,12 @@ def main():
474474
# Environment options
475475
env_options.add_argument(
476476
'-M', '--map-module', action='append', metavar='MAPPING',
477-
dest='module_mappings', default=[],
477+
dest='module_mappings',
478478
help='Add a module mapping',
479479
envvar='RFM_MODULE_MAPPINGS ,', configvar='general/module_mappings'
480480
)
481481
env_options.add_argument(
482-
'-m', '--module', action='append', default=[],
482+
'-m', '--module', action='append',
483483
metavar='MOD', dest='user_modules',
484484
help='Load module MOD before running any regression check',
485485
envvar='RFM_USER_MODULES ,', configvar='general/user_modules'
@@ -501,13 +501,13 @@ def main():
501501
envvar='RFM_NON_DEFAULT_CRAYPE', configvar='general/non_default_craype'
502502
)
503503
env_options.add_argument(
504-
'--purge-env', action='store_true', dest='purge_env', default=False,
504+
'--purge-env', action='store_true', dest='purge_env',
505505
help='Unload all modules before running any regression check',
506506
envvar='RFM_PURGE_ENVIRONMENT', configvar='general/purge_environment'
507507
)
508508
env_options.add_argument(
509509
'-u', '--unload-module', action='append', metavar='MOD',
510-
dest='unload_modules', default=[],
510+
dest='unload_modules',
511511
help='Unload module MOD before running any regression check',
512512
envvar='RFM_UNLOAD_MODULES ,', configvar='general/unload_modules'
513513
)

reframe/utility/osext.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -692,27 +692,26 @@ def git_repo_exists(url, timeout=5):
692692
return True
693693

694694

695-
def git_repo_hash(commit='HEAD', short=True, wd=None):
695+
def git_repo_hash(commit='HEAD', short=True, wd='.'):
696696
'''Return the SHA1 hash of a Git commit.
697697
698698
:arg commit: The commit to look at.
699699
:arg short: Return a short hash. This always corresponds to the first 8
700700
characters of the long hash. We don't rely on Git for the short hash,
701701
since depending on the version it might return either 7 or 8
702702
characters.
703-
:arg wd: Change to this directory before retrieving the hash. If ``None``,
704-
ReFrame's install prefix will be used.
703+
:arg wd: Change to this directory before retrieving the hash.
705704
:returns: The Git commit hash or ``None`` if the hash could not be
706705
retrieved.
706+
707+
.. versionchanged:: 4.6.1
708+
Default working directory is now ``.``.
707709
'''
708710
try:
709-
wd = wd or reframe.INSTALL_PREFIX
710-
with change_dir(wd):
711-
# Do not log this command, since we need to call this function
712-
# from the logger
713-
completed = run_command(f'git rev-parse {commit}',
714-
check=True, log=False)
715-
711+
# Do not log this command, since we need to call this function
712+
# from the logger
713+
completed = run_command(f'git -C {wd} rev-parse {commit}',
714+
check=True, log=False)
716715
except (SpawnedProcessError, FileNotFoundError):
717716
return None
718717

@@ -730,13 +729,14 @@ def reframe_version():
730729
If ReFrame's installation contains the repository metadata and the current
731730
version is a pre-release version, the repository's hash will be appended
732731
to the actual version.
733-
734732
'''
735-
repo_hash = git_repo_hash()
736-
if repo_hash and semver.VersionInfo.parse(reframe.VERSION).prerelease:
737-
return f'{reframe.VERSION}+{repo_hash}'
738-
else:
739-
return reframe.VERSION
733+
if (semver.VersionInfo.parse(reframe.VERSION).prerelease and
734+
os.path.exists(os.path.join(reframe.INSTALL_PREFIX, '.git'))):
735+
repo_hash = git_repo_hash(wd=reframe.INSTALL_PREFIX)
736+
if repo_hash:
737+
return f'{reframe.VERSION}+{repo_hash}'
738+
739+
return reframe.VERSION
740740

741741

742742
def expandvars(s):

0 commit comments

Comments
 (0)