1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-11 16:36:14 +01:00

Allow conf.config['getpac_default_project'] to be a list.

Added find_default_project() to process this list.
This commit is contained in:
Juergen Weigert 2011-03-09 16:10:48 +01:00
parent 9396d9c34d
commit 64f9dca08b
2 changed files with 34 additions and 9 deletions

View File

@ -1251,11 +1251,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if len(args) > 4:
raise oscerr.WrongArgs('Too many arguments.')
if len(args) == 0 and is_package_dir('.') and len(conf.config['getpac_default_project']):
if len(args) == 0 and is_package_dir('.') and find_default_project():
wd = os.curdir
devel_project = store_read_project(wd)
devel_package = package = store_read_package(wd)
project = conf.config['getpac_default_project']
project = find_default_project(self.get_api_url(), package)
else:
if len(args) < 3:
raise oscerr.WrongArgs('Too few arguments.')
@ -1595,11 +1595,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
"""
import cgi
if len(args) == 0 and is_package_dir('.') and len(conf.config['getpac_default_project']):
if len(args) == 0 and is_package_dir('.') and find_default_project():
wd = os.curdir
devel_project = store_read_project(wd)
devel_package = package = store_read_package(wd)
project = conf.config['getpac_default_project']
project = find_default_project(self.get_api_url(), package)
elif len(args) < 3:
raise oscerr.WrongArgs('Too few arguments.')
elif len(args) > 4:
@ -2548,7 +2548,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
home:USERNAME:branches:PROJECT/PACKAGE
if nothing else specified.
With getpac or bco, the branched package will come from
With getpac or bco, the branched package will come from one of
%(getpac_default_project)s
if nothing else specified.
@ -2567,9 +2567,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
tproject = tpackage = None
if (subcmd == 'getpac' or subcmd == 'bco') and len(args) == 1:
print >>sys.stderr, 'defaulting to %s/%s' % (conf.config['getpac_default_project'], args[0])
def_p = find_default_project(self.get_api_url(), args[0])
print >>sys.stderr, 'defaulting to %s/%s' % (def_p, args[0])
# python has no args.unshift ???
args = [ conf.config['getpac_default_project'] , args[0] ]
args = [ def_p, args[0] ]
if len(args) == 0 and is_package_dir('.'):
args = (store_read_project('.'), store_read_package('.'))
@ -5767,9 +5768,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
opts.devel_project = None
if len(args) == 1:
print >>sys.stderr, 'defaulting to %s/%s' % (conf.config['getpac_default_project'], args[0])
def_p = find_default_project(self.get_api_url(), args[0])
print >>sys.stderr, 'defaulting to %s/%s' % (def_p, args[0])
# python has no args.unshift ???
args = [ conf.config['getpac_default_project'] , args[0] ]
args = [ def_p, args[0] ]
return self.do_maintainer(subcmd, opts, *args)

View File

@ -6164,4 +6164,27 @@ def filter_role(meta, user, role):
for node in delete:
root.remove(node)
def find_default_project(apiurl=None, package=None):
""""
look though the list of conf.config['getpac_default_project']
and find the first project where the given package exists in the build service.
"""
if not len(conf.config['getpac_default_project']):
return None
candidates = re.split('[, ]+', conf.config['getpac_default_project'])
if package is None or len(candidates) == 1:
return candidates[0]
# search through the list, where package exists ...
for prj in candidates:
try:
# any fast query will do here.
show_package_meta(apiurl, prj, package)
return prj
except:
pass
return None
# vim: sw=4 et