Skip to content

Commit

Permalink
Tito report --nvr
Browse files Browse the repository at this point in the history
  • Loading branch information
praiskup committed Feb 21, 2024
1 parent 409f37b commit 9c99222
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tito/builder/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions src/tito/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down

0 comments on commit 9c99222

Please sign in to comment.