Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undocumented strip of "-" from tags #367

Open
bnavigator opened this issue Aug 8, 2020 · 5 comments
Open

Undocumented strip of "-" from tags #367

bnavigator opened this issue Aug 8, 2020 · 5 comments

Comments

@bnavigator
Copy link

Hypothesis uses tags in the form of hypothesis-python-%{version}. The following service definition does not work:

<services>
  <service name="obs_scm" mode="disabled">
    <param name="url">https://github.com/HypothesisWorks/hypothesis.git</param>
    <param name="scm">git</param>
    <param name="revision">hypothesis-python-5.23.11</param>
    <param name="versionformat">@PARENT_TAG@</param>
    <param name="versionrewrite-pattern">hypothesis-python-(.*)</param>
    <param name="subdir">hypothesis-python/tests</param>    
    <param name="filename">hypothesis-python-tests</param>    
  </service>  
</services>

Apparently the hyphens are stripped already in the versionformat, so the versionrewrite-pattern logic does not see it:

def version_iso_cleanup(self, version, debian=False):
"""Reformat timestamp value."""
version = re.sub(r'([0-9]{4})-([0-9]{2})-([0-9]{2}) +'
r'([0-9]{2})([:]([0-9]{2})([:]([0-9]{2}))?)?'
r'( +[-+][0-9]{3,4})',
r'\1\2\3T\4\6\8',
version)
# avoid removing "-" for Debian packages, which use it to split the
# upstream vs downstream version
# for RPM it has to be stripped instead, as it's an illegal character
if not debian:
version = re.sub(r'[-:]', '', version)
return version

Please document the strip or move it to after the rewrite.

For git, the value is passed to git log --date=short --pretty=format:...
for the topmost commit, and the output from git is cleaned up to
remove some unhelpful characters. Here are some useful examples of

"unhelpful characters" is not specific enough :(

@olafhering
Copy link
Contributor

This is broken.

The dashes are wiped before versionrewrite-pattern has a chance to see and process them. It is up to the author of the _service file to handle git tags with dashes in it.

@mar-v-in
Copy link

mar-v-in commented Mar 6, 2021

The updated behavior breaks existing implementations and also mismatches the documentation.

https://github.com/openSUSE/obs-service-tar_scm/blob/a019e6f/tar_scm.service.in#L83-L85

As "unhelpful characters" are no longer removed, hyphens from the %cd git date format end up in the final version string which can result in invalid version strings. The documentation claims that %cd results in the date without hyphens which was the previous behavior. Either the documentation should be updated to reflect the current implementation or any other system needs to be established to recover the useful behavior to strip hyphens from date formats.

@olafhering
Copy link
Contributor

%cd.%h resulted in 20200727.d95eb35. What is the current result of this format string?

@mar-v-in
Copy link

mar-v-in commented Mar 6, 2021

Would result in 2020-07-27.d95eb35. (at least when versionrewrite-pattern is set, not sure if that's relevant)

@hramrach
Copy link
Contributor

hramrach commented Apr 6, 2021

When using versionrewrite-pattern dashes should no longer be stripped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants