From 7e4be0c83492eefadc3283d09705cf590f16de67 Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: May 20 2015 09:21:22 +0000
Subject: [PATCH 1/2] Drop debugging code or adjust it to a configuration setting


---

diff --git a/pagure/hooks/files/fedmsg_hook.py b/pagure/hooks/files/fedmsg_hook.py
index b63e8ec..1716898 100755
--- a/pagure/hooks/files/fedmsg_hook.py
+++ b/pagure/hooks/files/fedmsg_hook.py
@@ -10,13 +10,12 @@ from collections import defaultdict
 import fedmsg
 import fedmsg.config
 
-sys.path.insert(0, os.path.expanduser('~/repos/gitrepo/pagure'))
 
 if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
-    print 'Using configuration file `/etc/pagure/pagure.cfg`'
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
+
 import pagure.lib.git
 
 abspath = os.path.abspath(os.environ['GIT_DIR'])
diff --git a/pagure/hooks/files/pagure_hook.py b/pagure/hooks/files/pagure_hook.py
index 98b12da..329293e 100755
--- a/pagure/hooks/files/pagure_hook.py
+++ b/pagure/hooks/files/pagure_hook.py
@@ -14,7 +14,6 @@ from sqlalchemy.exc import SQLAlchemyError
 
 if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
-    print 'Using configuration file `/etc/pagure/pagure.cfg`'
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
 
@@ -143,15 +142,17 @@ def run_as_post_receive_hook():
 
     changes = []
     for line in sys.stdin:
-        print line
+        if pagure.APP.config.get('HOOK_DEBUG', False):
+            print line
         (oldrev, newrev, refname) = line.strip().split(' ', 2)
 
-        print '  -- Old rev'
-        print oldrev
-        print '  -- New rev'
-        print newrev
-        print '  -- Ref name'
-        print refname
+        if pagure.APP.config.get('HOOK_DEBUG', False):
+            print '  -- Old rev'
+            print oldrev
+            print '  -- New rev'
+            print newrev
+            print '  -- Ref name'
+            print refname
 
         if set(newrev) == set(['0']):
             print "Deleting a reference/branch, so we won't run the "\
@@ -161,8 +162,9 @@ def run_as_post_receive_hook():
         generate_revision_change_log(
             pagure.lib.git.get_revs_between(oldrev, newrev, abspath))
 
-    print 'repo:', pagure.lib.git.get_repo_name(abspath)
-    print 'user:', pagure.lib.git.get_username(abspath)
+    if pagure.APP.config.get('HOOK_DEBUG', False):
+        print 'repo:', pagure.lib.git.get_repo_name(abspath)
+        print 'user:', pagure.lib.git.get_username(abspath)
 
 
 def main(args):
diff --git a/pagure/hooks/files/pagure_hook_requests.py b/pagure/hooks/files/pagure_hook_requests.py
index 49d5233..319e875 100755
--- a/pagure/hooks/files/pagure_hook_requests.py
+++ b/pagure/hooks/files/pagure_hook_requests.py
@@ -15,10 +15,8 @@ import subprocess
 # We need to access the database
 if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
-    print 'Using configuration file `/etc/pagure/pagure.cfg`'
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
-sys.path.insert(0, os.path.expanduser('~/repos/gitrepo/pagure'))
 
 import pagure.lib.git
 
@@ -46,15 +44,17 @@ def run_as_post_receive_hook():
 
     file_list = set()
     for line in sys.stdin:
-        print line
+        if pagure.APP.config.get('HOOK_DEBUG', False):
+            print line
         (oldrev, newrev, refname) = line.strip().split(' ', 2)
 
-        print '  -- Old rev'
-        print oldrev
-        print '  -- New rev'
-        print newrev
-        print '  -- Ref name'
-        print refname
+        if pagure.APP.config.get('HOOK_DEBUG', False):
+            print '  -- Old rev'
+            print oldrev
+            print '  -- New rev'
+            print newrev
+            print '  -- Ref name'
+            print refname
 
         if set(newrev) == set(['0']):
             print "Deleting a reference/branch, so we won't run the "\
diff --git a/pagure/hooks/files/pagure_hook_tickets.py b/pagure/hooks/files/pagure_hook_tickets.py
index 5e464a7..7a7d320 100755
--- a/pagure/hooks/files/pagure_hook_tickets.py
+++ b/pagure/hooks/files/pagure_hook_tickets.py
@@ -15,10 +15,8 @@ import subprocess
 # We need to access the database
 if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
-    print 'Using configuration file `/etc/pagure/pagure.cfg`'
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
-sys.path.insert(0, os.path.expanduser('~/repos/gitrepo/pagure'))
 
 import pagure.lib.git
 
@@ -46,15 +44,18 @@ def run_as_post_receive_hook():
 
     file_list = set()
     for line in sys.stdin:
-        print line
+        if pagure.APP.config.get('HOOK_DEBUG', False):
+            print line
         (oldrev, newrev, refname) = line.strip().split(' ', 2)
 
-        print '  -- Old rev'
-        print oldrev
-        print '  -- New rev'
-        print newrev
-        print '  -- Ref name'
-        print refname
+        if pagure.APP.config.get('HOOK_DEBUG', False):
+            print '  -- Old rev'
+            print oldrev
+            print '  -- New rev'
+            print newrev
+            print '  -- Ref name'
+            print refname
+
 
         if set(newrev) == set(['0']):
             print "Deleting a reference/branch, so we won't run the "\

From a7d75962f86aef25611ce48b19f6bd49c7696c4a Mon Sep 17 00:00:00 2001
From: Pierre-Yves Chibon <pingou@pingoured.fr>
Date: May 20 2015 09:22:27 +0000
Subject: [PATCH 2/2] Drop debugging code on the milter as well


---

diff --git a/milters/comment_email_milter.py b/milters/comment_email_milter.py
index 1027a72..ca5237f 100644
--- a/milters/comment_email_milter.py
+++ b/milters/comment_email_milter.py
@@ -26,11 +26,8 @@ logq = Queue(maxsize=4)
 
 if 'PAGURE_CONFIG' not in os.environ \
         and os.path.exists('/etc/pagure/pagure.cfg'):
-    print 'Using configuration file `/etc/pagure/pagure.cfg`'
     os.environ['PAGURE_CONFIG'] = '/etc/pagure/pagure.cfg'
 
-sys.path.insert(0, os.path.expanduser('/srv/progit'))
-
 
 import pagure
 

