diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-02-12 15:11:30 +0200 |
---|---|---|
committer | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2014-02-12 17:41:31 +0200 |
commit | 1cc54e35d192ea39160ef0e3b22bf403cac2a141 (patch) | |
tree | fe4073fb8ae66dd7c03ea9bd2dcce1ca810d875b | |
parent | 002a1bf55f0773ad38c6cd09cf552256da1bd53a (diff) | |
download | git-buildpackage-1cc54e35d192ea39160ef0e3b22bf403cac2a141.tar.gz git-buildpackage-1cc54e35d192ea39160ef0e3b22bf403cac2a141.tar.bz2 git-buildpackage-1cc54e35d192ea39160ef0e3b22bf403cac2a141.zip |
import-orig: implement --create-missing-branches option
Create the upstream branch if it does not exist. Use the same option
name that import-dsc has.
Change-Id: I32769cb3c03fd2e63f743b7a3aa0b18465bb7ce7
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
-rw-r--r-- | gbp/config.py | 3 | ||||
-rw-r--r-- | gbp/scripts/import_orig.py | 17 |
2 files changed, 14 insertions, 6 deletions
diff --git a/gbp/config.py b/gbp/config.py index 7445a8d6..ea5b505f 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -32,7 +32,8 @@ from gbp.git import GitRepositoryError, GitRepository no_upstream_branch_msg = """ Repository does not have branch '%s' 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. +on howto create it or check the --create-missing-branches option. Otherwise, +use --upstream-branch to specify it. """ def expand_path(option, opt, value): diff --git a/gbp/scripts/import_orig.py b/gbp/scripts/import_orig.py index d1ecea27..7c7cb06e 100644 --- a/gbp/scripts/import_orig.py +++ b/gbp/scripts/import_orig.py @@ -170,6 +170,9 @@ def parse_args(argv): branch_group.add_option("--upstream-vcs-tag", dest="vcs_tag", help="Upstream VCS tag add to the merge commit") branch_group.add_boolean_config_file_option(option_name="merge", dest="merge") + branch_group.add_boolean_config_file_option( + option_name="create-missing-branches", + dest="create_missing_branches") tag_group.add_boolean_config_file_option(option_name="sign-tags", dest="sign_tags") @@ -237,7 +240,11 @@ def main(argv): is_empty = False if initial_branch else True if not repo.has_branch(options.upstream_branch) and not is_empty: - raise GbpError(no_upstream_branch_msg % options.upstream_branch) + if options.create_missing_branches: + gbp.log.info("Will create missing branch '%s'" % + options.upstream_branch) + else: + raise GbpError(no_upstream_branch_msg % options.upstream_branch) (pkg_name, version) = detect_name_and_version(repo, source, options) @@ -282,10 +289,10 @@ def main(argv): parents = None commit = repo.commit_dir(unpacked_orig, - msg=msg, - branch=import_branch, - other_parents=parents, - ) + msg=msg, + branch=import_branch, + other_parents=parents, + create_missing_branch=options.create_missing_branches) if options.pristine_tar and pristine_orig: repo.pristine_tar.commit(pristine_orig, upstream_branch) |