option for notifications in un/tagBuildBypass

Fixes: https://pagure.io/koji/issue/690
This commit is contained in:
Tomas Kopecek 2017-11-09 15:49:54 +01:00
parent f9d3a73edd
commit b667f73c9c

View file

@ -9249,7 +9249,7 @@ class RootExports(object):
context.session.assertPerm('admin')
add_external_rpm(rpminfo, external_repo, strict=strict)
def tagBuildBypass(self, tag, build, force=False):
def tagBuildBypass(self, tag, build, force=False, notify=True):
"""Tag a build without running post checks or notifications
This is a short circuit function for imports.
@ -9260,7 +9260,16 @@ class RootExports(object):
of entries will affect which build is the latest)
"""
context.session.assertPerm('admin')
_tag_build(tag, build, force=force)
user_id = context.session.user_id
try:
_tag_build(tag, build, force=force)
if notify:
tag_notification(True, None, tag, build, user_id)
except Exception:
exctype, value = sys.exc_info()[:2]
if notify:
tag_notification(False, None, tag, build, user_id, False, "%s: %s" % (exctype, value))
raise
def tagBuild(self, tag, build, force=False, fromtag=None):
"""Request that a build be tagged
@ -9347,15 +9356,24 @@ class RootExports(object):
tag_notification(False, None, tag, build, user_id, False, "%s: %s" % (exctype, value))
raise
def untagBuildBypass(self, tag, build, strict=True, force=False):
"""Untag a build without any checks or notifications
def untagBuildBypass(self, tag, build, strict=True, force=False, notify=True):
"""Untag a build without any checks
Admins only. Intended for syncs/imports.
Unlike tagBuild, this does not create a task
No return value"""
context.session.assertPerm('admin')
_untag_build(tag, build, strict=strict, force=force)
user_id = context.session.user_id
try:
_untag_build(tag, build, strict=strict, force=force)
if notify:
tag_notification(True, None, tag, build, user_id)
except Exception:
exctype, value = sys.exc_info()[:2]
if notify:
tag_notification(False, None, tag, build, user_id, False, "%s: %s" % (exctype, value))
raise
def moveBuild(self, tag1, tag2, build, force=False):
"""Move a build from tag1 to tag2