osmith has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ci/+/40965?usp=email )
Change subject: OBS: --version-append: never override version ......................................................................
OBS: --version-append: never override version
We have some branches set up that when pushed to, directly result in building OBS packages. We append a string to the package version there, such as ~rhizomatica.testing. The expectation is that all packages built from that branch have this string in the version.
Recently an edge case was found: when amending the commit of the last tagged release, e.g. osmo-sgsn 1.12.0, then the generated version is based on the previous git tag (as the last git tag's commit is not part of the current branch anymore) while having the newer version in debian/changelog. This then results in the newer version being used, without appending the version string:
osmo-sgsn: WARNING: version from changelog (1.12.0) is higher than version based on git tag (1.11.1.20-e000e~rhizomatica.production), using version from changelog (git tag not pushed yet?)
While IMHO it is a bad idea to just amend the commit of the last release instead of making a separate commit, this results in unexpected behavior so adjust the script to not override the version if --version-append is used.
Related: OS#5981 Change-Id: I589ceb08b9e1ff2ccdd54e94216b25e1e40f22fe --- M scripts/obs/lib/debian.py 1 file changed, 6 insertions(+), 5 deletions(-)
Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified pespin: Looks good to me, but someone else must approve
diff --git a/scripts/obs/lib/debian.py b/scripts/obs/lib/debian.py index 9193d66..0438dd8 100644 --- a/scripts/obs/lib/debian.py +++ b/scripts/obs/lib/debian.py @@ -112,12 +112,13 @@ try: if packaging.version.parse(version_changelog.split("-")[0]) > packaging.version.parse(version.split("-")[0]): print( - f"{project}: WARNING: version from changelog" - f" ({version_changelog}) is higher than version based on git tag" - f" ({version}), using version from changelog (git tag not pushed" - " yet?)" + f"{project}: WARNING: version from changelog ({version_changelog}) is higher than version based on git tag ({version})" ) - return + if lib.args.version_append: + print(f"{project}: WARNING: assuming commit from last git tag was amended, ignoring...") + else: + print(f"{project}: WARNING: using version from changelog (git tag not pushed yet?)") + return except packaging.version.InvalidVersion: # packaging.version.parse can parse the version numbers used in Osmocom # projects (where we need the above check), but not e.g. some versions