On Fri, Aug 17, 2018 at 01:28:47PM +0200, Guido Günther wrote:
> Yeah, exactly. There are some external uses and we don't want to break
> API for them.

Aha!

OK, here's a new patch which does what you suggest.

Cheers,

-- 
Iain Lane                                  [ i...@orangesquash.org.uk ]
Debian Developer                                   [ la...@debian.org ]
Ubuntu Developer                                   [ la...@ubuntu.com ]
From 48d259ea6bd56f340a6bcde78e7d5d6bdb18c4bd Mon Sep 17 00:00:00 2001
From: Iain Lane <la...@debian.org>
Date: Fri, 17 Aug 2018 11:22:01 +0100
Subject: [PATCH] Ignore merge commits when looking at the pristine-tar branch

When there is a merge commit in this branch, we currently get the
warning:

  gbp:warning: Unknown compression type of Merge branch 'pristine-tar' into 'pristine-tar', assuming gzip

because we're grepping the commit logs to find out the compression type
of the tarballs in there.

For now, we can just use `git log ... --no-merges' to not see these
commits.
---
 gbp/git/repository.py      | 4 +++-
 gbp/pkg/pristinetar.py     | 2 +-
 gbp/scripts/export_orig.py | 2 +-
 tests/05_test_detection.py | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 1fc92ee9..827bf17b 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -1645,7 +1645,7 @@ class GitRepository(object):
             raise GitRepositoryError("can't get %s: %s" % (id, stderr.decode().rstrip()))
         return obj
 
-    def grep_log(self, regex, since=None):
+    def grep_log(self, regex, since=None, merges=True):
         """
         Get commmits matching I{regex}
 
@@ -1655,6 +1655,8 @@ class GitRepository(object):
         @type since: C{str}
         """
         args = ['--pretty=format:%H']
+        if not merges:
+            args.append("--no-merges")
         args.append("--grep=%s" % regex)
         if since:
             args.append(since)
diff --git a/gbp/pkg/pristinetar.py b/gbp/pkg/pristinetar.py
index 1da72bfb..be301326 100644
--- a/gbp/pkg/pristinetar.py
+++ b/gbp/pkg/pristinetar.py
@@ -71,7 +71,7 @@ class PristineTar(Command):
             return None
 
         regex = ('pristine-tar .* %s' % archive_regexp)
-        commits = self.repo.grep_log(regex, self.branch)
+        commits = self.repo.grep_log(regex, self.branch, merges=False)
         if commits:
             commit = commits[-1]
             gbp.log.debug("Found pristine-tar commit at '%s'" % commit)
diff --git a/gbp/scripts/export_orig.py b/gbp/scripts/export_orig.py
index 95b83da5..ea6c8870 100755
--- a/gbp/scripts/export_orig.py
+++ b/gbp/scripts/export_orig.py
@@ -236,7 +236,7 @@ def guess_comp_type(comp_type, source, repo, tarball_dir):
     if comp_type == 'auto':
         if repo and repo.has_pristine_tar_branch():
             regex = 'pristine-tar .* %s_%s\.orig.tar\.' % (source.name, source.upstream_version)
-            commits = repo.grep_log(regex, repo.pristine_tar_branch)
+            commits = repo.grep_log(regex, repo.pristine_tar_branch, merges=False)
             if commits:
                 commit = commits[-1]
                 gbp.log.debug("Found pristine-tar commit at '%s'" % commit)
diff --git a/tests/05_test_detection.py b/tests/05_test_detection.py
index d2579dfa..5e903db3 100644
--- a/tests/05_test_detection.py
+++ b/tests/05_test_detection.py
@@ -24,7 +24,7 @@ class MockGitRepository:
     def pristine_tar_branch(self):
         'pristine-tar'
 
-    def grep_log(self, regex, branch):
+    def grep_log(self, regex, branch, merges=True):
         return None
 
     def get_commit_info(self, commit):
-- 
2.17.0

Attachment: signature.asc
Description: PGP signature

Reply via email to