mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-27 23:16:14 +01:00
add validation verbose mode for easier debugging
This commit is contained in:
parent
1700744cfa
commit
6cbff920dc
@ -2405,6 +2405,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
help='force commit - do not tests a file list')
|
help='force commit - do not tests a file list')
|
||||||
@cmdln.option('--skip-validation', default=False, action="store_true",
|
@cmdln.option('--skip-validation', default=False, action="store_true",
|
||||||
help='Skip the source validation')
|
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):
|
def do_commit(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Upload content to the repository server
|
"""${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)
|
args = parseargs(args)
|
||||||
|
|
||||||
msg = ''
|
|
||||||
validators = conf.config['source_validator_directory']
|
validators = conf.config['source_validator_directory']
|
||||||
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. Skipping ..."
|
print "WARNING: validator directory", validators, "configured, but not existing. Skipping ..."
|
||||||
validators = None
|
validators = None
|
||||||
|
if opts.verbose_validation:
|
||||||
|
verbose_validation = 1
|
||||||
|
|
||||||
|
msg = ''
|
||||||
if opts.message:
|
if opts.message:
|
||||||
msg = opts.message
|
msg = opts.message
|
||||||
elif opts.file:
|
elif opts.file:
|
||||||
@ -2454,7 +2458,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if not msg:
|
if not msg:
|
||||||
msg = edit_message()
|
msg = edit_message()
|
||||||
try:
|
try:
|
||||||
Project(arg).commit(msg=msg, validators=validators)
|
Project(arg).commit(msg=msg, validators=validators, verbose_validation=verbose_validation)
|
||||||
except oscerr.RuntimeError, e:
|
except oscerr.RuntimeError, e:
|
||||||
print >>sys.stderr, "ERROR: source_validator failed", e
|
print >>sys.stderr, "ERROR: source_validator failed", e
|
||||||
return 1
|
return 1
|
||||||
@ -2505,19 +2509,19 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
single_paths.append(pac.dir)
|
single_paths.append(pac.dir)
|
||||||
for prj, packages in prj_paths.iteritems():
|
for prj, packages in prj_paths.iteritems():
|
||||||
try:
|
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:
|
except oscerr.RuntimeError, e:
|
||||||
print >>sys.stderr, "ERROR: source_validator failed", e
|
print >>sys.stderr, "ERROR: source_validator failed", e
|
||||||
return 1
|
return 1
|
||||||
for pac in single_paths:
|
for pac in single_paths:
|
||||||
try:
|
try:
|
||||||
Package(pac).commit(msg, validators=validators)
|
Package(pac).commit(msg, validators=validators, verbose_validation=verbose_validation)
|
||||||
except oscerr.RuntimeError, e:
|
except oscerr.RuntimeError, e:
|
||||||
print >>sys.stderr, "ERROR: source_validator failed", e
|
print >>sys.stderr, "ERROR: source_validator failed", e
|
||||||
return 1
|
return 1
|
||||||
else:
|
else:
|
||||||
for p in pacs:
|
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')
|
store_unlink_file(os.path.abspath('.'), '_commit_msg')
|
||||||
|
|
||||||
|
23
osc/core.py
23
osc/core.py
@ -614,7 +614,7 @@ class Project:
|
|||||||
finally:
|
finally:
|
||||||
self.write_packages()
|
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):
|
if len(pacs):
|
||||||
try:
|
try:
|
||||||
for pac in pacs:
|
for pac in pacs:
|
||||||
@ -623,7 +623,7 @@ class Project:
|
|||||||
todo = files[pac]
|
todo = files[pac]
|
||||||
state = self.get_state(pac)
|
state = self.get_state(pac)
|
||||||
if state == 'A':
|
if state == 'A':
|
||||||
self.commitNewPackage(pac, msg, todo)
|
self.commitNewPackage(pac, msg, todo, validators=validators, verbose_validation=verbose_validation)
|
||||||
elif state == 'D':
|
elif state == 'D':
|
||||||
self.commitDelPackage(pac)
|
self.commitDelPackage(pac)
|
||||||
elif state == ' ':
|
elif state == ' ':
|
||||||
@ -633,7 +633,7 @@ class Project:
|
|||||||
else:
|
else:
|
||||||
p = Package(os.path.join(self.dir, pac))
|
p = Package(os.path.join(self.dir, pac))
|
||||||
p.todo = todo
|
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)):
|
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
|
print 'osc: \'%s\' is not under version control' % pac
|
||||||
elif pac in self.pacs_broken:
|
elif pac in self.pacs_broken:
|
||||||
@ -653,15 +653,15 @@ class Project:
|
|||||||
state = self.get_state(pac)
|
state = self.get_state(pac)
|
||||||
if state == ' ':
|
if state == ' ':
|
||||||
# do a simple commit
|
# 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':
|
elif state == 'D':
|
||||||
self.commitDelPackage(pac)
|
self.commitDelPackage(pac)
|
||||||
elif state == 'A':
|
elif state == 'A':
|
||||||
self.commitNewPackage(pac, msg)
|
self.commitNewPackage(pac, msg, validators=validators, verbose_validation=verbose_validation)
|
||||||
finally:
|
finally:
|
||||||
self.write_packages()
|
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"""
|
"""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
|
||||||
@ -682,7 +682,7 @@ class Project:
|
|||||||
p = Package(os.path.join(self.dir, pac))
|
p = Package(os.path.join(self.dir, pac))
|
||||||
p.todo = files
|
p.todo = files
|
||||||
print statfrmt('Sending', os.path.normpath(p.dir))
|
print statfrmt('Sending', os.path.normpath(p.dir))
|
||||||
p.commit(msg)
|
p.commit(msg, validators=validators, verbose_validation=verbose_validation)
|
||||||
self.set_state(pac, ' ')
|
self.set_state(pac, ' ')
|
||||||
os.chdir(olddir)
|
os.chdir(olddir)
|
||||||
|
|
||||||
@ -899,7 +899,7 @@ class Package:
|
|||||||
|
|
||||||
shutil.copyfile(os.path.join(self.dir, n), os.path.join(self.storedir, n))
|
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
|
# 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:
|
||||||
@ -919,8 +919,11 @@ class Package:
|
|||||||
fn=validators+"/"+validator
|
fn=validators+"/"+validator
|
||||||
mode = os.stat(fn)
|
mode = os.stat(fn)
|
||||||
if S_ISREG(mode[ST_MODE]):
|
if S_ISREG(mode[ST_MODE]):
|
||||||
print "run", fn
|
if verbose_validation:
|
||||||
p = subprocess.Popen([fn], close_fds=True)
|
print "run", fn
|
||||||
|
p = subprocess.Popen([fn, "--verbose"], close_fds=True)
|
||||||
|
else:
|
||||||
|
p = subprocess.Popen([fn], close_fds=True)
|
||||||
if p.wait() != 0:
|
if p.wait() != 0:
|
||||||
raise oscerr.RuntimeError(p.stdout, validator )
|
raise oscerr.RuntimeError(p.stdout, validator )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user