From 9c9922218261aebbcc02b0618c8d031c153699f8 Mon Sep 17 00:00:00 2001 From: Pavel Raiskup Date: Wed, 21 Feb 2024 10:24:08 +0100 Subject: [PATCH] Tito report --nvr --- src/tito/builder/main.py | 8 ++++++++ src/tito/cli.py | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/tito/builder/main.py b/src/tito/builder/main.py index 348b57f0..b491289c 100644 --- a/src/tito/builder/main.py +++ b/src/tito/builder/main.py @@ -489,6 +489,14 @@ def _get_build_version(self): check_tag_exists(self.build_tag, offline=self.offline) return build_version + def get_raw_version_release(self): + """ + Parse the spec file in git, and report version-release + """ + return get_spec_version_and_release( + self.start_dir, + find_spec_like_file(self.start_dir)) + def _get_tag_for_version(self, version_and_release): """ Determine what the tag will look like for a given version. diff --git a/src/tito/cli.py b/src/tito/cli.py index 3d3a5207..eaee1b8e 100644 --- a/src/tito/cli.py +++ b/src/tito/cli.py @@ -813,7 +813,12 @@ def __init__(self): "which packages are in need of a re-tag.", )) + self.parser.add_option("--nvr", action="store_true") + def main(self, argv): + # TODO: + # --release|--version options + # --test option (now default) BaseCliModule.main(self, argv) if self.options.untagged_report: @@ -823,6 +828,19 @@ def main(self, argv): if self.options.untagged_commits: self._run_untagged_commits(self.config) sys.exit(1) + + if self.options.nvr: + build_dir = self.options.output_dir + package_name = get_project_name() + build_tag = None + self.load_config(package_name, build_dir, build_tag) + builder = create_builder(package_name, None, self.config, + build_dir, self.user_config, {}, test=True) + sha = builder.git_commit_id[:7] + rel_suffix = f'.git.{builder.commit_count}.{sha}' + print(f"{builder.project_name}-{builder.get_raw_version_release()}{rel_suffix}") + sys.exit(0) + return [] def _run_untagged_commits(self, config):