Hi Jonas,
On Fri, Nov 04, 2016 at 03:24:56PM +0100, Guido Günther wrote:
> Hi Jonas,
> On Mon, Oct 31, 2016 at 03:21:46PM +0100, Jonas Meurer wrote:
> > Hi Guido,
> > 
> > Am 31.10.2016 um 11:21 schrieb Guido Günther:
> > >> See attached patch which implements basic version mangling for
> > >> '--git-upstream-tag' in a simple substitute fashion: if the provided
> > >> format contains the syntax '%(version%OLD%NEW)s', then the version used
> > >> for '%(version)s' has 'OLD' replaced by 'NEW'.
> > >>
> > >> This allows us to let gbp create the upstream tarball from upstream Git
> > >> release tag for new releases:
> > >>
> > >> $ gbp buildpackage --git-upstream-tag="v%(version%.%_)s"
> > >>
> > >>
> > >> In case that you like the approach and agree to add this feature to gbp,
> > >> I could write a few corresponding words for the related paragraphs of
> > >> gbp documentation.
> > >>
> > >> If you're not happy with the way it's implmented, just let me know why
> > >> and we can search for a better solution :)
> > > 
> > > The general approach is fine. Thanks for the patch. See my comments below:
> > 
> > Great :) I  tried to address your comments, see below.
> > 
> > >> commit f6a7e8f83935d74dc0cd67a5afa26b243357d04f
> > >> Author: Jonas Meurer <jo...@freesources.org>
> > >> Date:   Sun Oct 30 23:44:34 2016 +0100
> > >>
> > >>     gbp/deb/git.py: add basic version mangling to version_to_tag()
> > >>
> > >> diff --git a/gbp/deb/git.py b/gbp/deb/git.py
> > >> index 64cd321..3070d93 100644
> > >> --- a/gbp/deb/git.py
> > >> +++ b/gbp/deb/git.py
> > >> @@ -142,12 +142,18 @@ class DebianGitRepository(GitRepository):
> > >>          hversion is useful for upstreams with tagging policies that 
> > >> prohibit .
> > >>          characters.
> > >>  
> > >> +        %(version%A%B)s provides %(version)s with 'A' replaced by 'B'.
> > >> +
> > > 
> > > Please add tests using docstrings as below (including one that show how
> > > to use '%' as a replacement (e.g. 0-1.2.3 -> 0%1.2.3.4 and as replaced
> > > pattern 0%1%2%3 -> 0.1.2.3).
> > 
> > Done.
> > 
> > >>          >>> DebianGitRepository.version_to_tag("debian/%(version)s", 
> > >> "0:0~0")
> > >>          'debian/0%0_0'
> > >>          >>> DebianGitRepository.version_to_tag("libfoo-%(hversion)s", 
> > >> "1.8.1")
> > >>          'libfoo-1-8-1'
> > >>  
> > >>          """
> > >> +        r = re.search(r"\%\(version\%([^%s]+)\%([^\%]+)\)s", format)
> > >> +        if r:
> > >> +            format = re.sub(r"\%\(version\%[^%s]+\%[^\%]+\)s", 
> > >> "%(version)s", format)
> > >> +            version = version.replace(r.group(1), r.group(2))
> > >>          return format_str(format, 
> > >> dict(version=DebianGitRepository._sanitize_version(version),
> > >>                                         
> > >> hversion=DebianGitRepository._sanitize_version(version).replace('.', 
> > >> '-')))
> > >>  
> > > 
> > > Please document the behaviour. The current place that has the most
> > > information on how to modify the upstream version is in
> > > 
> > >      docs/chapters/import.sgml
> > 
> > Done.
> > 
> > See the attached updated patch.

While looking into this in some more details I noticed that we're
missing the reverse operation. In 'gbp buildpackage' we need to map from
the Debian version to the upstream tag while in 'gbp dch' we need to
map from the upstream tag to the debian version. This is not reversible
since '_' will be mapped back to '~'. Therefore I added a warning to the
docs. I've also made some simplifications to allow for easier future
expansion like only allowing for single character replacements for now.

If you have some time it owuld be great if you could have a look
at these commits:

 0b317eeb649090ab8bdd8507c189477670a91cd1 docs: Use version mangling with care
 7ed5e2b5ffbaf8dec310f98162e653fc95cd45f9 DebianGitRepository: Unmangle version
 25a5d679daf6ca90e03fe3bede787396fc630687 DebianGitRepository: split out 
version mangling
 d360a6d92d744762f9f13555ed03726b6d4ba937 DebianGitRepository: simplify version 
mangling

Cheers,
 -- Guido

Reply via email to