mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-24 17:16:12 +01:00
run pre_checkin.sh on build and commit
The pre_checkin.sh is script run after each checkin of package into SUSE. Osc build and commit commands now runs it automatically too, unless --no-precheckin is specified.
This commit is contained in:
parent
ae13273045
commit
8ea5bc7f04
1
NEWS
1
NEWS
@ -1,4 +1,5 @@
|
|||||||
0.131
|
0.131
|
||||||
|
- call pre_checkin.sh on build and commit (can be suppressed with --no-precheckin)
|
||||||
|
|
||||||
0.130
|
0.130
|
||||||
- new "revert" command to restore the original working copy file (without
|
- new "revert" command to restore the original working copy file (without
|
||||||
|
@ -3084,6 +3084,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
help='Skip the source validation')
|
help='Skip the source validation')
|
||||||
@cmdln.option('--verbose-validation', default=False, action="store_true",
|
@cmdln.option('--verbose-validation', default=False, action="store_true",
|
||||||
help='Run the source validation with verbose information')
|
help='Run the source validation with verbose information')
|
||||||
|
@cmdln.option('--no-precheckin', action='store_true', default=False,
|
||||||
|
help="don't run pre_checkin.sh, if exists")
|
||||||
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
|
||||||
|
|
||||||
@ -3133,6 +3135,8 @@ 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)
|
||||||
|
if not opts.no_precheckin:
|
||||||
|
run_precheckin(prj.pacs_have)
|
||||||
prj.validate_pacs(validators, opts.verbose_validation)
|
prj.validate_pacs(validators, opts.verbose_validation)
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = edit_message()
|
msg = edit_message()
|
||||||
@ -3166,6 +3170,8 @@ 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)
|
||||||
|
if not opts.no_precheckin:
|
||||||
|
run_precheckin((os.path.join(prj_path, p) for p in packages))
|
||||||
prj.validate_pacs(validators, opts.verbose_validation, *packages)
|
prj.validate_pacs(validators, opts.verbose_validation, *packages)
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = get_commit_msg(prj.absdir, pac_objs[prj_path])
|
msg = get_commit_msg(prj.absdir, pac_objs[prj_path])
|
||||||
@ -3173,6 +3179,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
store_unlink_file(prj.absdir, '_commit_msg')
|
store_unlink_file(prj.absdir, '_commit_msg')
|
||||||
for pac in single_paths:
|
for pac in single_paths:
|
||||||
p = Package(pac)
|
p = Package(pac)
|
||||||
|
if not opts.no_precheckin:
|
||||||
|
run_precheckin()
|
||||||
p.validate(validators, opts.verbose_validation)
|
p.validate(validators, opts.verbose_validation)
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = get_commit_msg(p.absdir, [p])
|
msg = get_commit_msg(p.absdir, [p])
|
||||||
@ -3181,6 +3189,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
else:
|
else:
|
||||||
for p in pacs:
|
for p in pacs:
|
||||||
p = Package(pac)
|
p = Package(pac)
|
||||||
|
if not opts.no_precheckin:
|
||||||
|
run_precheckin()
|
||||||
p.validate(validators, opts.verbose_validation)
|
p.validate(validators, opts.verbose_validation)
|
||||||
if not msg:
|
if not msg:
|
||||||
msg = get_commit_msg(p.absdir, [p])
|
msg = get_commit_msg(p.absdir, [p])
|
||||||
@ -4092,7 +4102,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
repositories = []
|
repositories = []
|
||||||
# store list of repos for potential offline use
|
# store list of repos for potential offline use
|
||||||
repolistfile = os.path.join(os.getcwd(), osc.core.store, "_build_repositories")
|
repolistfile = os.path.join(os.getcwd(), store, "_build_repositories")
|
||||||
if noinit:
|
if noinit:
|
||||||
if os.path.exists(repolistfile):
|
if os.path.exists(repolistfile):
|
||||||
f = open(repolistfile, 'r')
|
f = open(repolistfile, 'r')
|
||||||
@ -4234,6 +4244,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
help='take previous build from DIR (special values: _self, _link)')
|
help='take previous build from DIR (special values: _self, _link)')
|
||||||
@cmdln.option('--shell', action='store_true',
|
@cmdln.option('--shell', action='store_true',
|
||||||
help=SUPPRESS_HELP)
|
help=SUPPRESS_HELP)
|
||||||
|
@cmdln.option('--no-precheckin', action='store_true', default=False,
|
||||||
|
help="don't run pre_checkin.sh, if exists")
|
||||||
def do_build(self, subcmd, opts, *args):
|
def do_build(self, subcmd, opts, *args):
|
||||||
"""${cmd_name}: Build a package on your local machine
|
"""${cmd_name}: Build a package on your local machine
|
||||||
|
|
||||||
@ -4316,6 +4328,9 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
if opts.offline and opts.preload:
|
if opts.offline and opts.preload:
|
||||||
raise oscerr.WrongOptions('--offline and --preload are mutually exclusive')
|
raise oscerr.WrongOptions('--offline and --preload are mutually exclusive')
|
||||||
|
|
||||||
|
if not opts.no_precheckin:
|
||||||
|
run_precheckin()
|
||||||
|
|
||||||
print 'Building %s for %s/%s' % (args[2], args[0], args[1])
|
print 'Building %s for %s/%s' % (args[2], args[0], args[1])
|
||||||
return osc.build.main(self.get_api_url(), opts, args)
|
return osc.build.main(self.get_api_url(), opts, args)
|
||||||
|
|
||||||
|
19
osc/core.py
19
osc/core.py
@ -5954,4 +5954,23 @@ def filter_role(meta, user, role):
|
|||||||
for node in delete:
|
for node in delete:
|
||||||
root.remove(node)
|
root.remove(node)
|
||||||
|
|
||||||
|
# run the pre_checkin.sh if exists
|
||||||
|
def run_precheckin(packages=('.', )):
|
||||||
|
oldpwd = os.getcwd()
|
||||||
|
for dir in packages:
|
||||||
|
if os.path.isdir(dir):
|
||||||
|
os.chdir(dir)
|
||||||
|
if os.path.isfile('pre_checkin.sh'):
|
||||||
|
ret = subprocess.call(["/bin/sh", "pre_checkin.sh"])
|
||||||
|
if ret != 0:
|
||||||
|
script_name = 'pre_checkin.sh'
|
||||||
|
if dir != '.':
|
||||||
|
script_name = "%s/%s" % (dir, script_name)
|
||||||
|
#XXX: an ugly hack to prevent ../package - to me it seems, there's a bug in do_commit
|
||||||
|
if script_name[:3] == '../':
|
||||||
|
script_name = script_name[3:]
|
||||||
|
raise oscerr.ExtRuntimeError("sh %s has failed with exit code %d, fix it or ignore using --no-precheckin" % (script_name, ret), script_name)
|
||||||
|
os.chdir(oldpwd)
|
||||||
|
return True
|
||||||
|
|
||||||
# vim: sw=4 et
|
# vim: sw=4 et
|
||||||
|
Loading…
Reference in New Issue
Block a user