Package: git-buildpackage
Version: 0.9.22
Severity: normal
Tags: patch
User: de...@kali.org
Usertags: origin-kali

Dear Maintainer,

When running 'gbp import-dsc ...', if gbp does not find the debian
branch, it shows an error message that mentions the upstream branch. It
proposes to use --upstream-branch=, while what's really needed is
--debian-branch=.

Logs:

  # initial failure
  $ gbp import-dsc apt:desktop-base/sid
  gbp:info: Downloading 'desktop-base/sid' using 'apt-get'...
  gbp:info: Tag 11.0.2 not found, importing Debian tarball
  gbp:error:
  Repository does not have branch 'master' for upstream sources. If there is 
none see
  
file:///usr/share/doc/git-buildpackage/manual-html/gbp.import.html#GBP.IMPORT.CONVERT
  on howto create it otherwise use --upstream-branch to specify it.

  Also check the --create-missing-branches option.

  # trying as suggested
  $ gbp import-dsc --upstream-branch=debian apt:desktop-base/sid
  gbp:info: Downloading 'desktop-base/sid' using 'apt-get'...
  gbp:info: Tag 11.0.2 not found, importing Debian tarball
  gbp:error:
  Repository does not have branch 'master' for upstream sources. If there is 
none see
  
file:///usr/share/doc/git-buildpackage/manual-html/gbp.import.html#GBP.IMPORT.CONVERT
  on howto create it otherwise use --upstream-branch to specify it.

  Also check the --create-missing-branches option.

  # in fact it's the debian branch!
  $ gbp import-dsc --debian-branch=debian apt:desktop-base/sid
  gbp:info: Downloading 'desktop-base/sid' using 'apt-get'...
  gbp:info: Tag 11.0.2 not found, importing Debian tarball
  gbp:info: Version '11.0.2' imported under '/home/user/src/desktop-base'

Thanks!

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

Kernel: Linux 5.10.0-3-amd64 (SMP w/8 CPU threads)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages git-buildpackage depends on:
ii  devscripts             2.21.1
ii  git                    1:2.30.1-1
ii  man-db                 2.9.4-2
ii  python3                3.9.1-1
ii  python3-dateutil       2.8.1-5
ii  python3-pkg-resources  52.0.0-1
ii  sensible-utils         0.0.14

Versions of packages git-buildpackage recommends:
ii  pristine-tar      1.49
ii  python3-requests  2.25.1+dfsg-2
ii  sbuild            0.81.2

Versions of packages git-buildpackage suggests:
pn  python3-notify2  <none>
ii  sudo             1.9.5p2-2
ii  unzip            6.0-26

-- no debconf information
>From c7a7d48462708dc6ed7f4813253c7aed9238aaeb Mon Sep 17 00:00:00 2001
From: Arnaud Rebillout <arna...@kali.org>
Date: Thu, 4 Mar 2021 21:23:48 +0700
Subject: [PATCH] import-dsc: Fix error message when missing debian branch

The error message mistakenly talks about the upstream branch when it
should be talking about the debian branch. Logs:

        # initial failure
        $ gbp import-dsc apt:desktop-base/sid
        gbp:info: Downloading 'desktop-base/sid' using 'apt-get'...
        gbp:info: Tag 11.0.2 not found, importing Debian tarball
        gbp:error:
        Repository does not have branch 'master' for upstream sources. If there 
is none see
        
file:///usr/share/doc/git-buildpackage/manual-html/gbp.import.html#GBP.IMPORT.CONVERT
        on howto create it otherwise use --upstream-branch to specify it.

        Also check the --create-missing-branches option.

        # trying as suggested
        $ gbp import-dsc --upstream-branch=debian apt:desktop-base/sid
        gbp:info: Downloading 'desktop-base/sid' using 'apt-get'...
        gbp:info: Tag 11.0.2 not found, importing Debian tarball
        gbp:error:
        Repository does not have branch 'master' for upstream sources. If there 
is none see
        
file:///usr/share/doc/git-buildpackage/manual-html/gbp.import.html#GBP.IMPORT.CONVERT
        on howto create it otherwise use --upstream-branch to specify it.

        Also check the --create-missing-branches option.

        # in fact it's the debian branch!
        $ gbp import-dsc --debian-branch=debian apt:desktop-base/sid
        gbp:info: Downloading 'desktop-base/sid' using 'apt-get'...
        gbp:info: Tag 11.0.2 not found, importing Debian tarball
        gbp:info: Version '11.0.2' imported under '/home/user/src/desktop-base'
---
 gbp/config.py             |  6 ++++++
 gbp/scripts/import_dsc.py | 14 ++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/gbp/config.py b/gbp/config.py
index 1ca8defd..d9e7c57e 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -39,6 +39,12 @@ 
file:///usr/share/doc/git-buildpackage/manual-html/gbp.import.html#GBP.IMPORT.CO
 on howto create it otherwise use --upstream-branch to specify it.
 """
 
+no_debian_branch_msg = """
+Repository does not have branch '%s' for packaging sources. If there is none 
see
+file:///usr/share/doc/git-buildpackage/manual-html/gbp.import.html#GBP.IMPORT.CONVERT
+on howto create it otherwise use --debian-branch to specify it.
+"""
+
 
 def expand_path(option, opt, value):
     value = os.path.expandvars(value)
diff --git a/gbp/scripts/import_dsc.py b/gbp/scripts/import_dsc.py
index d24ffa24..a74477a4 100644
--- a/gbp/scripts/import_dsc.py
+++ b/gbp/scripts/import_dsc.py
@@ -34,7 +34,7 @@ from gbp.git import rfc822_date_to_git
 from gbp.git.modifier import GitModifier
 from gbp.git.vfs import GitVfs
 from gbp.config import (GbpOptionParserDebian, GbpOptionGroup,
-                        no_upstream_branch_msg)
+                        no_debian_branch_msg, no_upstream_branch_msg)
 from gbp.errors import GbpError
 from gbp.scripts.common import ExitCodes, debug_exc
 from gbp.scripts.common import repo_setup
@@ -198,14 +198,14 @@ def apply_debian_patch(repo, source, dsc, 
upstream_commit, options):
         os.chdir(repo.path)
 
 
-def create_missing_branch(repo, branch, options):
+def create_missing_branch(repo, branch, options, err_msg):
     if not repo.has_branch(branch):
         if options.create_missing_branches:
             gbp.log.info("Creating missing branch '%s'" % branch)
             repo.create_branch(branch)
         else:
-            raise GbpError(no_upstream_branch_msg % branch +
-                           "\nAlso check the --create-missing-branches 
option.")
+            raise GbpError(err_msg + "\n"
+                           "Also check the --create-missing-branches option.")
 
 
 def import_native(repo, source, dsc, options):
@@ -217,7 +217,8 @@ def import_native(repo, source, dsc, options):
         branch = None
     else:
         branch = options.debian_branch
-        create_missing_branch(repo, branch, options)
+        create_missing_branch(repo, branch, options,
+                              no_debian_branch_msg % branch)
 
     author = get_author_from_changelog(source.unpacked)
     committer = get_committer_from_author(author, options)
@@ -248,7 +249,8 @@ def import_upstream(repo, source, dsc, options):
         branch = None
     else:
         branch = options.upstream_branch
-        create_missing_branch(repo, branch, options)
+        create_missing_branch(repo, branch, options,
+                              no_upstream_branch_msg % branch)
 
     author = committer = {}
     commit_msg = "Import %s" % msg
-- 
2.30.1

Reply via email to