1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-13 17:16:23 +01:00

add validation verbose mode for easier debugging

This commit is contained in:
Adrian Schröter 2010-05-22 08:51:04 +02:00
parent 1700744cfa
commit 6cbff920dc
2 changed files with 22 additions and 15 deletions

View File

@ -2405,6 +2405,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
help='force commit - do not tests a file list')
@cmdln.option('--skip-validation', default=False, action="store_true",
help='Skip the source validation')
@cmdln.option('--verbose-validation', default=False, action="store_true",
help='Run the source validation with verbose informations')
def do_commit(self, subcmd, opts, *args):
"""${cmd_name}: Upload content to the repository server
@ -2432,14 +2434,16 @@ Please submit there instead, or use --nodevelproject to force direct submission.
args = parseargs(args)
msg = ''
validators = conf.config['source_validator_directory']
if opts.skip_validation:
validators = None
elif not os.path.exists(validators):
print "WARNING: validator directory", validators, "configured, but not existing. Skipping ..."
validators = None
if opts.verbose_validation:
verbose_validation = 1
msg = ''
if opts.message:
msg = opts.message
elif opts.file:
@ -2454,7 +2458,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
if not msg:
msg = edit_message()
try:
Project(arg).commit(msg=msg, validators=validators)
Project(arg).commit(msg=msg, validators=validators, verbose_validation=verbose_validation)
except oscerr.RuntimeError, e:
print >>sys.stderr, "ERROR: source_validator failed", e
return 1
@ -2505,19 +2509,19 @@ Please submit there instead, or use --nodevelproject to force direct submission.
single_paths.append(pac.dir)
for prj, packages in prj_paths.iteritems():
try:
Project(prj).commit(tuple(packages), msg, files, validators=validators)
Project(prj).commit(tuple(packages), msg, files, validators=validators, verbose_validation=verbose_validation)
except oscerr.RuntimeError, e:
print >>sys.stderr, "ERROR: source_validator failed", e
return 1
for pac in single_paths:
try:
Package(pac).commit(msg, validators=validators)
Package(pac).commit(msg, validators=validators, verbose_validation=verbose_validation)
except oscerr.RuntimeError, e:
print >>sys.stderr, "ERROR: source_validator failed", e
return 1
else:
for p in pacs:
p.commit(msg, validators=validators)
p.commit(msg, validators=validators, verbose_validation=verbose_validation)
store_unlink_file(os.path.abspath('.'), '_commit_msg')

View File

@ -614,7 +614,7 @@ class Project:
finally:
self.write_packages()
def commit(self, pacs = (), msg = '', files = {}, validators = None):
def commit(self, pacs = (), msg = '', files = {}, validators = None, verbose_validation = None):
if len(pacs):
try:
for pac in pacs:
@ -623,7 +623,7 @@ class Project:
todo = files[pac]
state = self.get_state(pac)
if state == 'A':
self.commitNewPackage(pac, msg, todo)
self.commitNewPackage(pac, msg, todo, validators=validators, verbose_validation=verbose_validation)
elif state == 'D':
self.commitDelPackage(pac)
elif state == ' ':
@ -633,7 +633,7 @@ class Project:
else:
p = Package(os.path.join(self.dir, pac))
p.todo = todo
p.commit(msg, validators=validators)
p.commit(msg, validators=validators, verbose_validation=verbose_validation)
elif pac in self.pacs_unvers and not is_package_dir(os.path.join(self.dir, pac)):
print 'osc: \'%s\' is not under version control' % pac
elif pac in self.pacs_broken:
@ -653,15 +653,15 @@ class Project:
state = self.get_state(pac)
if state == ' ':
# do a simple commit
Package(os.path.join(self.dir, pac)).commit(msg, validators=validators)
Package(os.path.join(self.dir, pac)).commit(msg, validators=validators, verbose_validation=verbose_validation)
elif state == 'D':
self.commitDelPackage(pac)
elif state == 'A':
self.commitNewPackage(pac, msg)
self.commitNewPackage(pac, msg, validators=validators, verbose_validation=verbose_validation)
finally:
self.write_packages()
def commitNewPackage(self, pac, msg = '', files = []):
def commitNewPackage(self, pac, msg = '', files = [], validators = None, verbose_validation = None):
"""creates and commits a new package if it does not exist on the server"""
if pac in self.pacs_available:
print 'package \'%s\' already exists' % pac
@ -682,7 +682,7 @@ class Project:
p = Package(os.path.join(self.dir, pac))
p.todo = files
print statfrmt('Sending', os.path.normpath(p.dir))
p.commit(msg)
p.commit(msg, validators=validators, verbose_validation=verbose_validation)
self.set_state(pac, ' ')
os.chdir(olddir)
@ -899,7 +899,7 @@ class Package:
shutil.copyfile(os.path.join(self.dir, n), os.path.join(self.storedir, n))
def commit(self, msg='', validators=None):
def commit(self, msg='', validators=None, verbose_validation=None):
# commit only if the upstream revision is the same as the working copy's
upstream_rev = self.latest_rev()
if self.rev != upstream_rev:
@ -919,8 +919,11 @@ class Package:
fn=validators+"/"+validator
mode = os.stat(fn)
if S_ISREG(mode[ST_MODE]):
print "run", fn
p = subprocess.Popen([fn], close_fds=True)
if verbose_validation:
print "run", fn
p = subprocess.Popen([fn, "--verbose"], close_fds=True)
else:
p = subprocess.Popen([fn], close_fds=True)
if p.wait() != 0:
raise oscerr.RuntimeError(p.stdout, validator )