From 4c0f9560d479ab0b01025e45f05ef3e0aa4dab73 Mon Sep 17 00:00:00 2001 From: Juan Navarro Date: Fri, 7 Dec 2018 14:17:03 +0100 Subject: [PATCH 1/3] Add support for '--ignore-branch' to 'bgp pq import' --- gbp/scripts/pq.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index babff1c5..378cb15d 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -418,6 +418,7 @@ def build_parser(name): gbp.log.err(err) return None + parser.add_boolean_config_file_option(option_name="ignore-branch", dest="ignore_branch") parser.add_boolean_config_file_option(option_name="patch-numbers", dest="patch_numbers") parser.add_config_file_option(option_name="patch-num-format", dest="patch_num_format") parser.add_boolean_config_file_option(option_name="renumber", dest="renumber") @@ -481,7 +482,15 @@ def main(argv): return 1 try: - current = repo.get_branch() + try: + current = repo.get_branch() + except GitRepositoryError: + # Not being on any branch is OK with --ignore-branch + if options.ignore_branch: + current = repo.get_commits(num=1)[0] + else: + raise + if action == "export": export_patches(repo, current, options) elif action == "import": From 22fe91b9946b9f23ff234dc06714328d502d1903 Mon Sep 17 00:00:00 2001 From: Juan Navarro Date: Fri, 7 Dec 2018 14:18:08 +0100 Subject: [PATCH 2/3] Use abbreviated commit for 'patch-queue/' branch name --- gbp/scripts/pq.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 378cb15d..2c6d10e8 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -487,7 +487,9 @@ def main(argv): except GitRepositoryError: # Not being on any branch is OK with --ignore-branch if options.ignore_branch: - current = repo.get_commits(num=1)[0] + current = repo.get_commits(num=1, + options=["--pretty=format:%h"] # Force abbreviated commit hash + )[0] else: raise From a766cac12d7044296acc43a2d99305cf437449fb Mon Sep 17 00:00:00 2001 From: Juan Navarro Date: Fri, 7 Dec 2018 14:45:56 +0100 Subject: [PATCH 3/3] Fix flake8 E128 continuation line under-indented --- gbp/scripts/pq.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gbp/scripts/pq.py b/gbp/scripts/pq.py index 2c6d10e8..5be2fafb 100755 --- a/gbp/scripts/pq.py +++ b/gbp/scripts/pq.py @@ -487,7 +487,8 @@ def main(argv): except GitRepositoryError: # Not being on any branch is OK with --ignore-branch if options.ignore_branch: - current = repo.get_commits(num=1, + current = repo.get_commits( + num=1, options=["--pretty=format:%h"] # Force abbreviated commit hash )[0] else: