"""gbs clone entry point."""
# Determine upstream branch
- if args.upstream_branch:
- upstream_branch = args.upstream_branch
- else:
- upstream_branch = configmgr.get('upstream_branch', 'general')
- if args.packaging_branch:
- packaging_branch = args.packaging_branch
- else:
- packaging_branch = configmgr.get('packaging_branch', 'general')
+ upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch')
+ packaging_branch = configmgr.get_arg_conf(args, 'packaging_branch')
# Construct GBP cmdline arguments
gbp_args = ['dummy argv[0]',
'--color-scheme=magenta:green:yellow:red',
"""
Determine if the package is "native"
"""
- if args.upstream_branch:
- upstream_branch = args.upstream_branch
- else:
- upstream_branch = configmgr.get('upstream_branch', 'general')
+ upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch')
return not repo.has_branch(upstream_branch)
def get_packaging_dir(args):
"""
Determine the packaging dir to be used
"""
- if args.packaging_dir:
- path = args.packaging_dir
- else:
- path = configmgr.get('packaging_dir', 'general')
+ path = configmgr.get_arg_conf(args, 'packaging_dir')
return path.rstrip(os.sep)
def check_export_branches(repo, args):
remote_branches = {}
for branch in repo.get_remote_branches():
remote_branches[branch.split('/')[-1]] = branch
- if args.upstream_branch:
- upstream_branch = args.upstream_branch
- else:
- upstream_branch = configmgr.get('upstream_branch', 'general')
+ upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch')
# track upstream/pristine-tar branch
for br in [upstream_branch, 'pristine-tar']:
"""
Construct the cmdline argument list for git-buildpackage export
"""
- if args.upstream_branch:
- upstream_branch = args.upstream_branch
- else:
- upstream_branch = configmgr.get('upstream_branch', 'general')
- if args.upstream_tag:
- upstream_tag = args.upstream_tag
- else:
- upstream_tag = configmgr.get('upstream_tag', 'general')
+ upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch')
+ upstream_tag = configmgr.get_arg_conf(args, 'upstream_tag')
# transform variables from shell to python convention ${xxx} -> %(xxx)s
upstream_tag = re.sub(r'\$\{([^}]+)\}', r'%(\1)s', upstream_tag)
log.debug("Using upstream tag format: '%s'" % upstream_tag)
# Get patch squashing option
- if args.squash_patches_until:
- squash_patches_until = args.squash_patches_until
- else:
- squash_patches_until = configmgr.get('squash_patches_until', 'general')
+ squash_patches_until = configmgr.get_arg_conf(args, 'squash_patches_until')
# Determine the remote repourl
reponame = ""
dirn=configmgr.get('tmpdir', 'general'),
directory=True)
- if args.upstream_branch:
- upstream_branch = args.upstream_branch
- else:
- upstream_branch = configmgr.get('upstream_branch', 'general')
- if args.upstream_tag:
- upstream_tag = args.upstream_tag
- else:
- upstream_tag = configmgr.get('upstream_tag', 'general')
+ upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch')
+ upstream_tag = configmgr.get_arg_conf(args, 'upstream_tag')
# transform variables from shell to python convention ${xxx} -> %(xxx)s
upstream_tag = re.sub(r'\$\{([^}]+)\}', r'%(\1)s', upstream_tag)
"""gbs pull entry point."""
# Determine upstream branch
- if args.upstream_branch:
- upstream_branch = args.upstream_branch
- else:
- upstream_branch = configmgr.get('upstream_branch', 'general')
+ upstream_branch = configmgr.get_arg_conf(args, 'upstream_branch')
# Construct GBP cmdline arguments
gbp_args = ['dummy argv[0]',
else:
return self._get(opt, section)
+ def get_arg_conf(self, args, opt, section='general'):
+ """get value from command line arguments if found there, otherwise fall
+ back to config
+ """
+ if hasattr(args, opt):
+ value = getattr(args, opt)
+ if value is not None:
+ return value
+ return self.get(opt, section)
+
@staticmethod
def update(cfgparsers):
'update changed values into files on disk'