changeset 2407:8a68e0292232 beta

Change git & hg hooks to post. They shouldn't block as they are used just for logging actions. Futhermore post hooks have access to changesets, so it's much better flexible
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 06 Jun 2012 22:23:27 +0200
parents 7be31af5bc78
children 89875fb6739a
files rhodecode/lib/hooks.py rhodecode/lib/middleware/simplegit.py rhodecode/model/db.py rhodecode/model/forms.py rhodecode/model/repo.py rhodecode/templates/admin/settings/settings.html
diffstat 6 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/hooks.py	Wed Jun 06 21:48:53 2012 +0200
+++ b/rhodecode/lib/hooks.py	Wed Jun 06 22:23:27 2012 +0200
@@ -138,7 +138,7 @@
 
         stop, start = get_revs(repo, [node + ':'])
         h = binascii.hexlify
-        revs = (h(repo[r].node()) for r in xrange(start, stop + 1))
+        revs = [h(repo[r].node()) for r in xrange(start, stop + 1)]
     elif scm == 'git':
         revs = kwargs.get('_git_revs', [])
         if '_git_revs' in kwargs:
@@ -198,7 +198,7 @@
 
 def handle_git_post_receive(repo_path, revs, env):
     """
-    A really hacky method that is runned by git pre-receive hook and logs
+    A really hacky method that is runned by git post-receive hook and logs
     an push action together with pushed revisions. It's runned by subprocess
     thus needs all info to be able to create a temp pylons enviroment, connect
     to database and run the logging code. Hacky as sh**t but works. ps.
--- a/rhodecode/lib/middleware/simplegit.py	Wed Jun 06 21:48:53 2012 +0200
+++ b/rhodecode/lib/middleware/simplegit.py	Wed Jun 06 22:23:27 2012 +0200
@@ -271,7 +271,7 @@
 
     def _handle_githooks(self, repo_name, action, baseui, environ):
         """
-        Handles pull action, push is handled by pre-receive hook
+        Handles pull action, push is handled by post-receive hook
         """
         from rhodecode.lib.hooks import log_pull_action
         service = environ['QUERY_STRING'].split('=')
--- a/rhodecode/model/db.py	Wed Jun 06 21:48:53 2012 +0200
+++ b/rhodecode/model/db.py	Wed Jun 06 22:23:27 2012 +0200
@@ -238,7 +238,7 @@
 
     HOOK_UPDATE = 'changegroup.update'
     HOOK_REPO_SIZE = 'changegroup.repo_size'
-    HOOK_PUSH = 'pretxnchangegroup.push_logger'
+    HOOK_PUSH = 'changegroup.push_logger'
     HOOK_PULL = 'preoutgoing.pull_logger'
 
     ui_id = Column("ui_id", Integer(), nullable=False, unique=True, default=None, primary_key=True)
--- a/rhodecode/model/forms.py	Wed Jun 06 21:48:53 2012 +0200
+++ b/rhodecode/model/forms.py	Wed Jun 06 22:23:27 2012 +0200
@@ -731,7 +731,7 @@
         paths_root_path = All(ValidPath(), UnicodeString(strip=True, min=1, not_empty=True))
         hooks_changegroup_update = OneOf(['True', 'False'], if_missing=False)
         hooks_changegroup_repo_size = OneOf(['True', 'False'], if_missing=False)
-        hooks_pretxnchangegroup_push_logger = OneOf(['True', 'False'], if_missing=False)
+        hooks_changegroup_push_logger = OneOf(['True', 'False'], if_missing=False)
         hooks_preoutgoing_pull_logger = OneOf(['True', 'False'], if_missing=False)
 
     return _ApplicationUiSettingsForm
--- a/rhodecode/model/repo.py	Wed Jun 06 21:48:53 2012 +0200
+++ b/rhodecode/model/repo.py	Wed Jun 06 22:23:27 2012 +0200
@@ -476,7 +476,7 @@
             tmpl = pkg_resources.resource_string(
                 'rhodecode', jn('config', 'pre_receive_tmpl.py')
             )
-            _hook_file = jn(loc, 'pre-receive')
+            _hook_file = jn(loc, 'post-receive')
             with open(_hook_file, 'wb') as f:
                 f.write(tmpl)
             os.chmod(_hook_file, 0555)
--- a/rhodecode/templates/admin/settings/settings.html	Wed Jun 06 21:48:53 2012 +0200
+++ b/rhodecode/templates/admin/settings/settings.html	Wed Jun 06 22:23:27 2012 +0200
@@ -148,8 +148,8 @@
 						<label for="hooks_changegroup_repo_size">${_('Show repository size after push')}</label>
 					</div>
                     <div class="checkbox">
-                        ${h.checkbox('hooks_pretxnchangegroup_push_logger','True')}
-                        <label for="hooks_pretxnchangegroup_push_logger">${_('Log user push commands')}</label>
+                        ${h.checkbox('hooks_changegroup_push_logger','True')}
+                        <label for="hooks_changegroup_push_logger">${_('Log user push commands')}</label>
                     </div>
                     <div class="checkbox">
                         ${h.checkbox('hooks_preoutgoing_pull_logger','True')}