- Update to version 1680160876.6dcaef0:

* Bump version: 0.0.6 → 0.0.7
  * Fix default value for empty or missing version
  * Bump flake8 from 5.0.1 to 5.0.4

OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/obs-service-replace_using_package_version?expand=0&rev=16
This commit is contained in:
David Cassany 2023-03-30 07:27:22 +00:00 committed by Git OBS Bridge
parent 4012585222
commit 51cc6c8f52
4 changed files with 19 additions and 11 deletions

View File

@ -1,4 +1,4 @@
<servicedata> <servicedata>
<service name="tar_scm"> <service name="tar_scm">
<param name="url">https://github.com/openSUSE/obs-service-replace_using_package_version.git</param> <param name="url">https://github.com/openSUSE/obs-service-replace_using_package_version.git</param>
<param name="changesrevision">71deb28fee3d2bd774404ee4018080fbb47a6247</param></service></servicedata> <param name="changesrevision">6dcaef0f89b089ac6f83200ce25c0d907e45111a</param></service></servicedata>

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Thu Mar 30 07:25:53 UTC 2023 - containers@suse.com
- Update to version 1680160876.6dcaef0:
* Bump version: 0.0.6 → 0.0.7
* Fix default value for empty or missing version
* Bump flake8 from 5.0.1 to 5.0.4
------------------------------------------------------------------- -------------------------------------------------------------------
Thu Nov 10 14:26:46 UTC 2022 - containers@suse.com Thu Nov 10 14:26:46 UTC 2022 - containers@suse.com

View File

@ -1,7 +1,7 @@
# #
# spec file # spec file
# #
# Copyright (c) 2022 SUSE LLC # Copyright (c) 2023 SUSE LLC
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -19,7 +19,7 @@
%define service replace_using_package_version %define service replace_using_package_version
Name: obs-service-%{service} Name: obs-service-%{service}
Version: 0.0.6 Version: 0.0.7
Release: 0 Release: 0
Summary: An OBS service: Replaces a regex with the version value of a package Summary: An OBS service: Replaces a regex with the version value of a package
License: GPL-3.0-or-later License: GPL-3.0-or-later

View File

@ -161,22 +161,22 @@ def apply_regex_to_file(input_file, output_file, regex, replacement):
def find_package_version(package, rpm_dir): def find_package_version(package, rpm_dir):
version = parse_version('') version = None
try: try:
version = get_pkg_version(package) version = get_pkg_version(package)
except Exception: except Exception:
version = find_package_version_in_local_repos(rpm_dir, package) version = find_package_version_in_local_repos(rpm_dir, package)
if not str(version): if version is None:
version = find_package_version_in_obsinfo('.', package) version = find_package_version_in_obsinfo('.', package)
if not str(version): if version is None:
raise Exception('Package version not found') raise Exception('Package version not found')
return str(version) return str(version)
def find_package_version_in_local_repos(repo_path, package): def find_package_version_in_local_repos(repo_path, package):
version = parse_version('') version = None
for root, _, files in os.walk(repo_path): for root, _, files in os.walk(repo_path):
packages = [ packages = [
f for f in files if f.endswith('rpm') and package in f f for f in files if f.endswith('rpm') and package in f
@ -185,17 +185,17 @@ def find_package_version_in_local_repos(repo_path, package):
rpm_file = os.path.join(root, pkg) rpm_file = os.path.join(root, pkg)
if get_pkg_name_from_rpm(rpm_file) == package: if get_pkg_name_from_rpm(rpm_file) == package:
rpm_ver = get_pkg_version_from_rpm(rpm_file) rpm_ver = get_pkg_version_from_rpm(rpm_file)
if rpm_ver >= version: if version is None or rpm_ver >= version:
version = rpm_ver version = rpm_ver
return version return version
def find_package_version_in_obsinfo(path, package): def find_package_version_in_obsinfo(path, package):
version = parse_version('') version = None
for f in os.listdir(path): for f in os.listdir(path):
if f.endswith('obsinfo') and package in f: if f.endswith('obsinfo') and package in f:
obsinfo_ver = get_pkg_version_from_obsinfo(f) obsinfo_ver = get_pkg_version_from_obsinfo(f)
if obsinfo_ver >= version: if version is None or obsinfo_ver >= version:
version = obsinfo_ver version = obsinfo_ver
return version return version
@ -219,7 +219,7 @@ def get_pkg_version_from_obsinfo(obsinfo_file):
match = regex.match(line) match = regex.match(line)
if match: if match:
return parse_version(match[1]) return parse_version(match[1])
return parse_version('') return None
def get_pkg_name_from_rpm(rpm_file): def get_pkg_name_from_rpm(rpm_file):