1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-02-24 19:22:13 +01:00

- added validator params to "commitExtPackage"

- use True/False instead of 1/None for the "verbose_validation" parameter
This commit is contained in:
Marcus Huewe 2010-09-09 12:49:53 +02:00
parent 4a19faadf3
commit fdc43cd9a2
2 changed files with 17 additions and 28 deletions

View File

@ -3009,15 +3009,12 @@ Please submit there instead, or use --nodevelproject to force direct submission.
args = parseargs(args) args = parseargs(args)
validators = conf.config['source_validator_directory'] validators = conf.config['source_validator_directory']
verbose_validation = None
if opts.skip_validation: if opts.skip_validation:
validators = None validators = None
elif not os.path.exists(validators): elif not os.path.exists(validators):
print "WARNING: validator directory", validators, "configured, but not existing (please install osc-source_validator). Skipping ..." print "WARNING: validator directory", validators, "configured, but not existing (please install osc-source_validator). Skipping ..."
validators = None validators = None
if opts.verbose_validation:
verbose_validation = 1
msg = '' msg = ''
if opts.message: if opts.message:
msg = opts.message msg = opts.message
@ -3032,7 +3029,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if conf.config['do_package_tracking'] and is_project_dir(arg): if conf.config['do_package_tracking'] and is_project_dir(arg):
try: try:
prj = Project(arg) prj = Project(arg)
prj.validate_pacs(validators, verbose_validation) prj.validate_pacs(validators, opts.verbose_validation)
if not msg: if not msg:
msg = edit_message() msg = edit_message()
prj.commit(msg=msg) prj.commit(msg=msg)
@ -3065,20 +3062,20 @@ Please submit there instead, or use --nodevelproject to force direct submission.
single_paths.append(pac.dir) single_paths.append(pac.dir)
for prj_path, packages in prj_paths.iteritems(): for prj_path, packages in prj_paths.iteritems():
prj = Project(prj_path) prj = Project(prj_path)
prj.validate_pacs(validators, verbose_validation, *packages) prj.validate_pacs(validators, opts.verbose_validation, *packages)
if not msg: if not msg:
msg = get_commit_msg(pac_objs[prj_path]) msg = get_commit_msg(pac_objs[prj_path])
prj.commit(packages, msg=msg, files=files) prj.commit(packages, msg=msg, files=files)
for pac in single_paths: for pac in single_paths:
p = Package(pac) p = Package(pac)
p.validate(validators, verbose_validation) p.validate(validators, opts.verbose_validation)
if not msg: if not msg:
msg = get_commit_msg([p]) msg = get_commit_msg([p])
p.commit(msg) p.commit(msg)
else: else:
for p in pacs: for p in pacs:
p = Package(pac) p = Package(pac)
p.validate(validators, verbose_validation) p.validate(validators, opts.verbose_validation)
if not msg: if not msg:
msg = get_commit_msg([p]) msg = get_commit_msg([p])
p.commit(msg) p.commit(msg)

View File

@ -654,7 +654,7 @@ class Project:
p = Package(os.path.join(self.dir, pac)) p = Package(os.path.join(self.dir, pac))
p.validate(validators, verbose_validation) p.validate(validators, verbose_validation)
def commit(self, pacs = (), msg = '', files = {}, validators_dir = None, verbose_validation = None): def commit(self, pacs = (), msg = '', files = {}, validators_dir = None, verbose_validation = False):
if len(pacs): if len(pacs):
try: try:
for pac in pacs: for pac in pacs:
@ -679,7 +679,7 @@ class Project:
elif pac in self.pacs_broken: elif pac in self.pacs_broken:
print 'osc: \'%s\' package not found' % pac print 'osc: \'%s\' package not found' % pac
elif state == None: elif state == None:
self.commitExtPackage(pac, msg, todo) self.commitExtPackage(pac, msg, todo, validators_dir=validators_dir, verbose_validation=verbose_validation)
finally: finally:
self.write_packages() self.write_packages()
else: else:
@ -701,7 +701,7 @@ class Project:
finally: finally:
self.write_packages() self.write_packages()
def commitNewPackage(self, pac, msg = '', files = [], validators_dir = None, verbose_validation = None): def commitNewPackage(self, pac, msg = '', files = [], validators_dir = None, verbose_validation = False):
"""creates and commits a new package if it does not exist on the server""" """creates and commits a new package if it does not exist on the server"""
if pac in self.pacs_available: if pac in self.pacs_available:
print 'package \'%s\' already exists' % pac print 'package \'%s\' already exists' % pac
@ -748,7 +748,7 @@ class Project:
delete_package(self.apiurl, self.name, pac) delete_package(self.apiurl, self.name, pac)
self.del_package_node(pac) self.del_package_node(pac)
def commitExtPackage(self, pac, msg, files = []): def commitExtPackage(self, pac, msg, files = [], validators_dir=None, verbose_validation=False):
"""commits a package from an external project""" """commits a package from an external project"""
if os_path_samefile(os.path.join(self.dir, pac), os.getcwd()): if os_path_samefile(os.path.join(self.dir, pac), os.getcwd()):
pac_path = '.' pac_path = '.'
@ -758,24 +758,16 @@ class Project:
project = store_read_project(pac_path) project = store_read_project(pac_path)
package = store_read_package(pac_path) package = store_read_package(pac_path)
apiurl = store_read_apiurl(pac_path) apiurl = store_read_apiurl(pac_path)
if meta_exists(metatype='pkg', if not meta_exists(metatype='pkg',
path_args=(quote_plus(project), quote_plus(package)), path_args=(quote_plus(project), quote_plus(package)),
template_args=None, template_args=None, create_new=False, apiurl=apiurl):
create_new=False, apiurl=apiurl):
p = Package(pac_path)
p.todo = files
p.commit(msg)
else:
user = conf.get_apiurl_usr(self.apiurl) user = conf.get_apiurl_usr(self.apiurl)
edit_meta(metatype='pkg', edit_meta(metatype='pkg',
path_args=(quote_plus(project), quote_plus(package)), path_args=(quote_plus(project), quote_plus(package)),
template_args=({ template_args=({'name': pac, 'user': user}), apiurl=apiurl)
'name': pac, p = Package(pac_path)
'user': user}), p.todo = files
apiurl=apiurl) p.commit(msg=msg, validators_dir=validators_dir, verbose_validation=verbose_validation)
p = Package(pac_path)
p.todo = files
p.commit(msg)
def __str__(self): def __str__(self):
r = [] r = []
@ -1085,7 +1077,7 @@ class Package:
if p.wait() != 0: if p.wait() != 0:
raise oscerr.ExtRuntimeError('ERROR: source_validator failed:\n%s' % p.stdout, validator) raise oscerr.ExtRuntimeError('ERROR: source_validator failed:\n%s' % p.stdout, validator)
def commit(self, msg='', validators_dir=None, verbose_validation=None): def commit(self, msg='', validators_dir=None, verbose_validation=False):
# commit only if the upstream revision is the same as the working copy's # commit only if the upstream revision is the same as the working copy's
upstream_rev = self.latest_rev() upstream_rev = self.latest_rev()
if self.rev != upstream_rev: if self.rev != upstream_rev: