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:
parent
9396d9c34d
commit
64f9dca08b
@ -1251,11 +1251,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if len(args) > 4:
|
if len(args) > 4:
|
||||||
raise oscerr.WrongArgs('Too many arguments.')
|
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
|
wd = os.curdir
|
||||||
devel_project = store_read_project(wd)
|
devel_project = store_read_project(wd)
|
||||||
devel_package = package = store_read_package(wd)
|
devel_package = package = store_read_package(wd)
|
||||||
project = conf.config['getpac_default_project']
|
project = find_default_project(self.get_api_url(), package)
|
||||||
else:
|
else:
|
||||||
if len(args) < 3:
|
if len(args) < 3:
|
||||||
raise oscerr.WrongArgs('Too few arguments.')
|
raise oscerr.WrongArgs('Too few arguments.')
|
||||||
@ -1595,11 +1595,11 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
"""
|
"""
|
||||||
import cgi
|
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
|
wd = os.curdir
|
||||||
devel_project = store_read_project(wd)
|
devel_project = store_read_project(wd)
|
||||||
devel_package = package = store_read_package(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:
|
elif len(args) < 3:
|
||||||
raise oscerr.WrongArgs('Too few arguments.')
|
raise oscerr.WrongArgs('Too few arguments.')
|
||||||
elif len(args) > 4:
|
elif len(args) > 4:
|
||||||
@ -2548,7 +2548,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
home:USERNAME:branches:PROJECT/PACKAGE
|
home:USERNAME:branches:PROJECT/PACKAGE
|
||||||
if nothing else specified.
|
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
|
%(getpac_default_project)s
|
||||||
if nothing else specified.
|
if nothing else specified.
|
||||||
|
|
||||||
@ -2567,9 +2567,10 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
tproject = tpackage = None
|
tproject = tpackage = None
|
||||||
|
|
||||||
if (subcmd == 'getpac' or subcmd == 'bco') and len(args) == 1:
|
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 ???
|
# 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('.'):
|
if len(args) == 0 and is_package_dir('.'):
|
||||||
args = (store_read_project('.'), store_read_package('.'))
|
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
|
opts.devel_project = None
|
||||||
|
|
||||||
if len(args) == 1:
|
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 ???
|
# 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)
|
return self.do_maintainer(subcmd, opts, *args)
|
||||||
|
|
||||||
|
|
||||||
|
23
osc/core.py
23
osc/core.py
@ -6164,4 +6164,27 @@ def filter_role(meta, user, role):
|
|||||||
for node in delete:
|
for node in delete:
|
||||||
root.remove(node)
|
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
|
# vim: sw=4 et
|
||||||
|
Loading…
Reference in New Issue
Block a user