Hello community,
here is the log from the commit of package
obs-service-replace_using_package_version for openSUSE:Factory checked in at
2019-06-26 16:03:52
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/obs-service-replace_using_package_version
(Old)
and
/work/SRC/openSUSE:Factory/.obs-service-replace_using_package_version.new.4615
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "obs-service-replace_using_package_version"
Wed Jun 26 16:03:52 2019 rev:3 rq:711909 version:0.0.3
Changes:
--------
---
/work/SRC/openSUSE:Factory/obs-service-replace_using_package_version/obs-service-replace_using_package_version.changes
2018-10-09 15:54:15.070276788 +0200
+++
/work/SRC/openSUSE:Factory/.obs-service-replace_using_package_version.new.4615/obs-service-replace_using_package_version.changes
2019-06-26 16:03:56.263621219 +0200
@@ -1,0 +2,7 @@
+Tue Jun 25 15:22:55 UTC 2019 - [email protected]
+
+- Update to version 1561476096.079b75f:
+ * Bump version: 0.0.2 → 0.0.3
+ * new patch_update and offset parameters (bsc#1139343)
+
+-------------------------------------------------------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ obs-service-replace_using_package_version.spec ++++++
--- /var/tmp/diff_new_pack.pSzIsb/_old 2019-06-26 16:03:57.059622346 +0200
+++ /var/tmp/diff_new_pack.pSzIsb/_new 2019-06-26 16:03:57.063622351 +0200
@@ -1,5 +1,5 @@
#
-# spec file for package obs-service-replace_using_package_version
+# spec file for package obs-service-replace_with_package_version
#
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
#
@@ -14,13 +14,10 @@
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
-
-
-#
%define service replace_using_package_version
Name: obs-service-%{service}
-Version: 0.0.2
+Version: 0.0.3
Release: 0
Summary: An OBS service: Replaces a regex with the version value of a
package
License: GPL-3.0-or-later
@@ -29,12 +26,12 @@
Source0: %{service}.tar
%if 0%{?suse_version} > 1315
BuildRequires: python3-setuptools
-Requires: python3-docopt
Requires: python3-setuptools
+Requires: python3-docopt
%else
BuildRequires: python-setuptools
-Requires: python-docopt
Requires: python-setuptools
+Requires: python-docopt
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.pSzIsb/_old 2019-06-26 16:03:57.103622408 +0200
+++ /var/tmp/diff_new_pack.pSzIsb/_new 2019-06-26 16:03:57.107622413 +0200
@@ -1,4 +1,4 @@
<servicedata>
<service name="tar_scm">
<param
name="url">https://github.com/openSUSE/obs-service-replace_using_package_version.git</param>
- <param
name="changesrevision">d0e12bd2a9d638b630e37f88659261c942a841d6</param></service></servicedata>
\ No newline at end of file
+ <param
name="changesrevision">079b75f7ce19941a04a22fa00055867497e7812e</param></service></servicedata>
\ No newline at end of file
++++++ replace_using_package_version.tar ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/replace_using_package_version/.bumpversion.cfg
new/replace_using_package_version/.bumpversion.cfg
--- old/replace_using_package_version/.bumpversion.cfg 2018-10-09
09:13:17.000000000 +0200
+++ new/replace_using_package_version/.bumpversion.cfg 2019-06-25
17:21:36.000000000 +0200
@@ -1,5 +1,5 @@
[bumpversion]
-current_version = 0.0.2
+current_version = 0.0.3
commit = True
tag = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/replace_using_package_version/README.md
new/replace_using_package_version/README.md
--- old/replace_using_package_version/README.md 2018-10-09 09:13:17.000000000
+0200
+++ new/replace_using_package_version/README.md 2019-06-25 17:21:36.000000000
+0200
@@ -44,13 +44,31 @@
The service in this case would look for the `mariadb` package in the build
environment, get its version, and try to replace any occurrence of `%%TAG%%`
-in `mariadb-imgae.kiwi` file with the `mariadb` package version.
+in `mariadb-image.kiwi` file with the `mariadb` package version.
-The `parse-version` states to use only up to the minor version part for a given
-versio string. For instance, in this specific case, the service will
-apply the `^(\d+(\.\d+){0,1})` regular expression and use only the first match.
+The `parse-version` could be skipped or if parameter's regular expression
+doesn't match then full package version is returned.
+
+Possible `parse-version` values and it returned value in X.Y.Z.N version:
+
+* `major`: `^(\d+)`, returns X
+* `minor`: `^(\d+(\.\d+){0,1})`, returns X.Y
+* `patch`: `^(\d+(\.\d+){0,2})`, returns X.Y.Z
+* `patch_update`: `^(\d+(\.\d+){0,3})`, returns X.Y.Z.N
+* `offset`: `^(?:\d+(?:\.\d+){0,3})[+-.~](?:git|svn|cvs)(\d+)`
+ * returns X.Y.Z.N as it doesn't match
+ * but if you have offset in your version X.Y.Z+git5 it returns 5
+* `parse-version` is absent or parameter doesn't match, returns X.Y.Z.N
+
+For instance, in this specific case, the service will apply the
+`^(\d+(\.\d+){0,1})` regular expression and use only the first match.
In case `mariadb` version was `10.3.4~git_r154` only the `10.3` part would be
used as the replacement string.
+You could use this service multiple times in your `_service` file so `offset`
+parameter could be used in case you need more unique identification.
+For example %%TAG%%.%%OFFSET%% if you add another service with `regex`
"%%OFFSET%%"
+and `parse-version` "offset".
+
This service is mainly designed to work in `buildtime` mode, so it is applied
inside the build environment just before the start of the build.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/replace_using_package_version/obs-service-replace_using_package_version.spec
new/replace_using_package_version/obs-service-replace_using_package_version.spec
---
old/replace_using_package_version/obs-service-replace_using_package_version.spec
2018-10-09 09:13:17.000000000 +0200
+++
new/replace_using_package_version/obs-service-replace_using_package_version.spec
2019-06-25 17:21:36.000000000 +0200
@@ -17,7 +17,7 @@
%define service replace_using_package_version
Name: obs-service-%{service}
-Version: 0.0.2
+Version: 0.0.3
Release: 0
Summary: An OBS service: Replaces a regex with the version value of a
package
License: GPL-3.0-or-later
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/replace_using_package_version/replaceUsingPackageVersion/replace_using_package_version.py
new/replace_using_package_version/replaceUsingPackageVersion/replace_using_package_version.py
---
old/replace_using_package_version/replaceUsingPackageVersion/replace_using_package_version.py
2018-10-09 09:13:17.000000000 +0200
+++
new/replace_using_package_version/replaceUsingPackageVersion/replace_using_package_version.py
2019-06-25 17:21:36.000000000 +0200
@@ -36,8 +36,9 @@
--replacement=REPLACEMENT : replacement string for any match
--regex=REGEX : regular expression for parsing file
--parse-version=DEPTH : parse the package version string to match
- major.minor.patch format. It can be set
- to 'major', 'minor' or 'patch'.
+ major.minor.patch.patch_update format.
+ It can be set to 'major', 'minor',
+ 'patch, patch_update and offset.
"""
import docopt
import re
@@ -45,6 +46,14 @@
import subprocess
from pkg_resources import parse_version
+version_regex = {
+ 'major': r'^(\d+)',
+ 'minor': r'^(\d+(\.\d+){0,1})',
+ 'patch': r'^(\d+(\.\d+){0,2})',
+ 'patch_update': r'^(\d+(\.\d+){0,3})',
+ 'offset': r'^(?:\d+(?:\.\d+){0,3})[+-.~](?:git|svn|cvs)(\d+)'
+}
+
def main():
"""
@@ -53,12 +62,6 @@
# TODO: probably there is a better way to set the repositories path
rpm_dir = './repos'
- version_regex = {
- 'major': '^(\d+)',
- 'minor': '^(\d+(\.\d+){0,1})',
- 'patch': '^(\d+(\.\d+){0,2})'
- }
-
command_args = docopt.docopt(__doc__)
if not os.path.isfile(command_args['--file']):
@@ -79,7 +82,7 @@
if parse_version and parse_version not in version_regex.keys():
raise Exception((
'Invalid value for this flag. Expected format is: '
- '--parse-version=[major|minor|patch]'
+ '--parse-version=[major|minor|patch|patch_update|offset]'
))
elif parse_version:
version = find_match_in_version(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/replace_using_package_version/test/replace_using_package_version_test.py
new/replace_using_package_version/test/replace_using_package_version_test.py
---
old/replace_using_package_version/test/replace_using_package_version_test.py
2018-10-09 09:13:17.000000000 +0200
+++
new/replace_using_package_version/test/replace_using_package_version_test.py
2019-06-25 17:21:36.000000000 +0200
@@ -7,7 +7,8 @@
find_match_in_version,
main,
run_command,
- init
+ init,
+ version_regex
)
open_to_patch = '{0}.open'.format(
@@ -32,17 +33,63 @@
))
def test_find_match_in_version(self):
- match = find_match_in_version('^(\d+)', '0.0.1')
+ match = find_match_in_version(version_regex['major'], '0.0.1')
assert match == '0'
- match = find_match_in_version('^(\d+(\.\d+){0,1})', '0.0.1~rev+af232f')
+ match = find_match_in_version(
+ version_regex['minor'],
+ '0.0.1~rev+af232f')
assert match == '0.0'
- match = find_match_in_version('^(\d+(\.\d+){0,2})', '0.0.1~rev+af232f')
+
+ match = find_match_in_version(
+ version_regex['patch'],
+ '0.0.1~rev+af232f')
assert match == '0.0.1'
- match = find_match_in_version('^(\d+(\.\d+){0,2})', '234~rev+af232f')
+ match = find_match_in_version(
+ version_regex['patch'],
+ '234~rev+af232f')
assert match == '234'
- match = find_match_in_version('^(\d+(\.\d+){0,1})', 'as234~rev+af232f')
+
+ match = find_match_in_version(
+ version_regex['minor'], 'as234~rev+af232f')
assert match == 'as234~rev+af232f'
+ match = find_match_in_version(
+ version_regex['patch_update'], '234~rev+af232f')
+ assert match == '234'
+ match = find_match_in_version(
+ version_regex['patch_update'],
+ '14.2.1.468+g994fd9e0cc')
+ assert match == '14.2.1.468'
+ match = find_match_in_version(
+ version_regex['patch_update'],
+ '0.0.1~rev+af232f')
+ assert match == '0.0.1'
+
+ match = find_match_in_version(
+ version_regex['offset'],
+ '3.14.1+git5.g9265358')
+ assert match == '5'
+ match = find_match_in_version(
+ version_regex['offset'],
+ '3.14.1+svn592')
+ assert match == '592'
+ match = find_match_in_version(
+ version_regex['offset'],
+ '2.14.1+cvs20130621')
+ assert match == '20130621'
+ match = find_match_in_version(
+ version_regex['offset'],
+ '0.0.1~rev+af232f')
+ assert match == '0.0.1~rev+af232f'
+ match = find_match_in_version(
+ version_regex['offset'],
+ '234~rev+af232f')
+ assert match == '234~rev+af232f'
+ match = find_match_in_version(
+ version_regex['offset'],
+ '14.2.1.468+g994fd9e0cc')
+ assert match == '14.2.1.468+g994fd9e0cc'
+
@patch((
'replaceUsingPackageVersion.'
'replace_using_package_version.run_command'
@@ -191,7 +238,7 @@
'file', 'outdir/file', 'regex', '0.0'
)
mock_match_version.assert_called_once_with(
- '^(\d+(\.\d+){0,1})', '0.0.1'
+ version_regex['minor'], '0.0.1'
)
@patch((