[git-buildpackage] extra newline in gbp.deb.changelog

Ken Dreyer kdreyer at redhat.com
Mon Nov 6 23:21:46 CET 2017


Here's a really simple debian/changelog file:

$ cat debian/changelog
testpkg (1.0.0-1) xenial; urgency=low

  * Initial package

 -- Ken Dreyer <kdreyer at redhat.com>  Tue, 06 Jun 2017 14:46:37 -0600


The following code works slightly differently between Python 2 (eg.
git-buildpackage 0.7.2) and Python 3 (with gbp master):

    from gbp.deb.changelog import ChangeLog
    clog = ChangeLog(filename='debian/changelog')
    clog['Changes']

In Python 2 (old gbp versions), the clog['Changes'] string is not
prefixed with a newline. It simply starts with the first line of
debian/changelog (well, prefixed by dpkg-parsechangelog's
indentation). In Python 3 (gbp master), the string always starts with
a spurious newline as the first character.

The key difference is that Python 2's message_from_string() would
discard the newline that dpkg-parsechangelog prints after "Changes:".
Python 3 does not discard this newline.

I'm not sure what is more "correct".

Does it make sense for gbp to go back to the old behavior?

We could do something like:

diff --git a/gbp/deb/changelog.py b/gbp/deb/changelog.py
index 33d83c1..e6c9176 100644
--- a/gbp/deb/changelog.py
+++ b/gbp/deb/changelog.py
@@ -118,6 +118,11 @@ class ChangeLog(object):
                 cp['Upstream-Version'], cp['Debian-Version'] =
cp['NoEpoch-Version'].rsplit('-', 1)
             else:
                 cp['Debian-Version'] = cp['NoEpoch-Version']
+            # py3's email.message_from_string() saves dpkg-parsechangelog's
+            # first newline from the "Changes" field.
+            changes = cp['Changes'].lstrip("\n")
+            del cp['Changes']
+            cp['Changes'] = changes
         except TypeError:
             raise ParseChangeLogError(output.split('\n')[0])


If not, I can handle this difference in my wrapper application. I'm
curious what others think about this.

My end goal is to get the actual "Changes" (bulleted items) in the
/debian/changelog file. Maybe I should make my application just scan
all text "Changes" text until it finds " .\n", since that is
unchanging here.


More information about the git-buildpackage mailing list