Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug #915629: Allow --ignore-branch for 'gbp pq' #64

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion gbp/scripts/pq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -481,7 +482,18 @@ 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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "branch name" is o.k. but did you verify e.g. "gbp switch" works with this? It would be good to have a test in tests/component/deb/test_pq.py that makes sure we don't break this behavior. Most of the functions called assume it's a branch we're working on.

options=["--pretty=format:%h"] # Force abbreviated commit hash
)[0]
else:
raise

if action == "export":
export_patches(repo, current, options)
elif action == "import":
Expand Down