From b667f73c9c239e7bf15ca8f0e880289df2a768d4 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: May 02 2018 10:33:58 +0000 Subject: option for notifications in un/tagBuildBypass Fixes: https://pagure.io/koji/issue/690 --- diff --git a/hub/kojihub.py b/hub/kojihub.py index 814d89e..0993d81 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -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