import-dsc: Fix error message when missing debian branch
authorArnaud Rebillout <arnaudr@kali.org>
Thu, 4 Mar 2021 14:23:48 +0000 (21:23 +0700)
committerGuido Günther <agx@sigxcpu.org>
Sat, 28 May 2022 10:15:24 +0000 (12:15 +0200)
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'

Closes: #984516
gbp/config.py
gbp/scripts/import_dsc.py

index aa626343256f52e8ff1438d05b85a43b56c80782..e5a0abc78efc41fdb22b93c4c92ad178a4872e51 100644 (file)
@@ -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)
index d24ffa2497c291b0149ace9cd8d937bbb90496bd..a74477a46cf06fb7c985f0ebe78cb8769350aab4 100644 (file)
@@ -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