Bug#923087: gbp-dch: fails to enumerate commits when log.showSignature is true in git config

2019-02-23 Thread Gabriel Filion
I've formatted a patch for upstream that fixes this behaviour. See file
attached
From 42582015feef85b760932c05e802e2f65418a19c Mon Sep 17 00:00:00 2001
From: Gabriel Filion 
Date: Sat, 23 Feb 2019 20:03:41 -0500
Subject: [PATCH] Disable PGP signatures when retrieving list of commits

gbp dch errors out with the following output if the "log.showSignature"
git config is enabled:

$ gbp dch --verbose
gbp:debug: ['git', 'rev-parse', '--show-cdup']
gbp:debug: ['git', 'rev-parse', '--is-bare-repository']
gbp:debug: ['git', 'rev-parse', '--git-dir']
gbp:debug: ['git', 'symbolic-ref', 'HEAD']
gbp:debug: ['git', 'show-ref', 'refs/heads/master']
gbp:debug: ['git', 'tag', '-l', 'debian/2.7.3-2']
gbp:debug: ['git', 'tag', '-l', 'debian/2.7.3-2']
gbp:debug: ['git', 'log', '--pretty=format:%H', '-1', '--', 'debian/changelog']
gbp:info: Changelog last touched at 'gpg: Signature made Fri 01 Feb 2019 03:56:19 PM EST'
gbp:debug: ['git', 'log', '--pretty=format:%H', 'gpg: Signature made Fri 01 Feb 2019 03:56:19 PM EST..HEAD', '--no-merges', '--']
fatal: bad revision 'gpg: Signature made Fri 01 Feb 2019 03:56:19 PM EST..HEAD'
gbp:error: Error getting commits gpg: Signature made Fri 01 Feb 2019 03:56:19 PM EST..HEAD

This is caused by gbp dch receiving unexpected output for the PGP
signatures and trying to use this unexpected output.

To avoid any surprises, let's disable signatures being output when we
list commits.

Also, when collecting a shortlog-like output from commit objects, the
same unexpected PGP signature output is sprayed all over the changelog.
We'll avoid this by also disable showing signatures when showing each
commit's first line.
---
 gbp/git/repository.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index a44c71e1..dfc8e556 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1613,7 +1613,7 @@ class GitRepository(object):
  merge commit
 @type first_parent: C{bool}
 """
-args = GitArgs('--pretty=format:%H')
+args = GitArgs('--pretty=format:%H', '--no-show-signature')
 args.add_true(num, '-%d' % num)
 args.add_true(first_parent, '--first-parent')
 if since:
@@ -1694,7 +1694,7 @@ class GitRepository(object):
 commit_sha1 = self.rev_parse("%s^0" % commitish)
 args = GitArgs('--pretty=format:%an%x00%ae%x00%ad%x00%cn%x00%ce%x00%cd%x00%s%x00%f%x00%b%x00',
'-z', '--date=raw', '--no-renames', '--name-status',
-   commit_sha1)
+   '--no-show-signature', commit_sha1)
 out, err, ret = self._git_inout('show', args.args)
 if ret:
 raise GitRepositoryError("Unable to retrieve commit info for %s"
-- 
2.20.1



signature.asc
Description: OpenPGP digital signature


Bug#923087: gbp-dch: fails to enumerate commits when log.showSignature is true in git config

2019-02-23 Thread Gabriel Filion
Package: git-buildpackage
Version: 0.9.13
Severity: normal

Hi,

I'm having difficulty running gbp dch. I get the following output (with
--verbose set):

pkg-smokeping$ gbp dch --verbose
gbp:debug: ['git', 'rev-parse', '--show-cdup']
gbp:debug: ['git', 'rev-parse', '--is-bare-repository']
gbp:debug: ['git', 'rev-parse', '--git-dir']
gbp:debug: ['git', 'symbolic-ref', 'HEAD']
gbp:debug: ['git', 'show-ref', 'refs/heads/master']
gbp:debug: ['git', 'tag', '-l', 'debian/2.7.3-2']
gbp:debug: ['git', 'tag', '-l', 'debian/2.7.3-2']
gbp:debug: ['git', 'log', '--pretty=format:%H', '-1', '--', 'debian/changelog']
gbp:info: Changelog last touched at 'gpg: Signature made Fri 01 Feb 2019 
03:56:19 PM EST'
gbp:debug: ['git', 'log', '--pretty=format:%H', 'gpg: Signature made Fri 01 Feb 
2019 03:56:19 PM EST..HEAD', '--no-merges', '--']
fatal: bad revision 'gpg: Signature made Fri 01 Feb 2019 03:56:19 PM EST..HEAD'
gbp:error: Error getting commits gpg: Signature made Fri 01 Feb 2019 03:56:19 
PM EST..HEAD

It's trying to get a commit that is actually a PGP signature.

I have found that this is caused by the fact that I have configured git
to always show PGP signatures. In order to replicate, you can configure
this option with:

git config log.showSignature true

If this option is disabled, then gbp dch works correctly.

I believe that a simple fix for this issue would be to force-disable the
option when calling git log: simply adding --no-show-signature to the
arguments should do the trick. This way, gbp dch would avoid receiving
the unexpected PGP signature output.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.19.0-1-amd64 (SMP w/4 CPU cores)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_CA.utf8, LC_CTYPE=en_CA.utf8 (charmap=UTF-8) (ignored: LC_ALL 
set to en_CA.utf8), LANGUAGE=en_CA.utf8 (charmap=UTF-8) (ignored: LC_ALL set to 
en_CA.utf8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages git-buildpackage depends on:
ii  devscripts 2.19.2
ii  git1:2.20.1-2
ii  man-db 2.8.5-2
ii  python33.7.2-1
ii  python3-dateutil   2.7.3-3
ii  python3-pkg-resources  40.8.0-1
ii  sensible-utils 0.0.12

Versions of packages git-buildpackage recommends:
ii  cowbuilder0.88
ii  pbuilder  0.230.1
ii  pristine-tar  1.46
ii  python3-requests  2.21.0-1
ii  sbuild0.78.1-1

Versions of packages git-buildpackage suggests:
ii  python3-notify2  0.3-3
ii  sudo 1.8.27-1
ii  unzip6.0-22

-- no debconf information