From d828b7da029994130b3717855155e49d58ee87ea Mon Sep 17 00:00:00 2001 From: crouzet Date: Wed, 6 Feb 2019 15:52:37 +0100 Subject: [PATCH] =?utf8?q?sat=20#8581=20:=20ajout=20d'une=20fonctionnalit?= =?utf8?q?=C3=A9=20de=20description=20fine=20de=20la=20version=20de=20salo?= =?utf8?q?meTool=20bas=C3=A9e=20sur=20git=20describe?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- commands/package.py | 4 ++-- src/__init__.py | 16 ++++++++++++++++ src/logger.py | 2 +- src/salomeTools.py | 2 +- src/system.py | 15 +++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/commands/package.py b/commands/package.py index 99bd2d1..5335863 100644 --- a/commands/package.py +++ b/commands/package.py @@ -1209,7 +1209,7 @@ The procedure to do it is: d = dict() d['user'] = config.VARS.user d['date'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M") - d['version'] = config.INTERNAL.sat_version + d['version'] = src.get_salometool_version(config) d['dist'] = config.VARS.dist f.write(readme_header_tpl.substitute(d)) # write the general header (common) @@ -1396,7 +1396,7 @@ Please add it in file: archive_name += ("PROJECT-" + project_name) if options.sat: - archive_name += ("salomeTools_" + runner.cfg.INTERNAL.sat_version) + archive_name += ("salomeTools_" + src.get_salometool_version(runner.cfg)) if len(archive_name)==0: # no option worked msg = _("Error: Cannot name the archive\n" " check if at least one of the following options was " diff --git a/src/__init__.py b/src/__init__.py index 02f27a6..ca569a0 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -228,6 +228,22 @@ def get_log_path(config): return log_dir_path +def get_salometool_version(config): + """Return the salomeTool version. + + :param config Config: The global Config instance. + :return: the description of this version of sat in terms of tag and commit + """ + # we use : + # config.VARS.salometoolsway : the full path of salomeTool + # config.INTERNAL.sat_version : the static salomeTool version, + # in case we are not in a git repo + sat_version=system.git_describe(config.VARS.salometoolsway) + if sat_version == False: + return config.INTERNAL.sat_version + else: + return sat_version + def get_salome_version(config): import versionMinorMajorPatch as VMMP diff --git a/src/logger.py b/src/logger.py index 439b540..545ac0b 100755 --- a/src/logger.py +++ b/src/logger.py @@ -134,7 +134,7 @@ class Logger(object): self.config.VARS.command}) # version of salomeTools self.xmlFile.append_node_attrib("Site", attrib={"satversion" : - self.config.INTERNAL.sat_version}) + src.get_salometool_version(self.config)}) # machine name on which the command has been launched self.xmlFile.append_node_attrib("Site", attrib={"hostname" : self.config.VARS.hostname}) diff --git a/src/salomeTools.py b/src/salomeTools.py index 251d6ea..543baea 100755 --- a/src/salomeTools.py +++ b/src/salomeTools.py @@ -696,7 +696,7 @@ def get_version(): cfgManager = CONFIG.ConfigManager() cfg = cfgManager.get_config() # print the key corresponding to salomeTools version - msg = (src.printcolors.printcHeader( _("Version: ") ) + cfg.INTERNAL.sat_version) + msg = (src.printcolors.printcHeader( _("Version: ") ) + src.get_salometool_version(cfg)) return msg diff --git a/src/system.py b/src/system.py index 6e7a788..6b79339 100644 --- a/src/system.py +++ b/src/system.py @@ -54,6 +54,21 @@ def show_in_editor(editor, filePath, logger): logger.write(printcolors.printcError(_("Unable to edit file %s\n") % filePath), 1) +def git_describe(repo_path): + '''Use git describe --tags command to return tag description of the git repository" + :param repo_path str: The git repository to describe + ''' + git_cmd="cd %s;git describe --tags" % repo_path + p = subprocess.Popen(git_cmd, shell=True, + stdin=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + p.wait() + if p.returncode != 0: + return False + else: + return p.stdout.readlines()[0].strip() + def git_extract(from_what, tag, where, logger, environment=None): '''Extracts sources from a git repository. -- 2.39.2