changeset 2818:3d0bd5f71dab beta

raise na OSERROR if repository data sent from git hook to hook handler is somehow invalid
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 06 Sep 2012 17:54:08 +0200
parents 3ae42e10b665
children bbaf0b86a1fe
files rhodecode/lib/hooks.py
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/hooks.py	Thu Sep 06 11:32:36 2012 +0200
+++ b/rhodecode/lib/hooks.py	Thu Sep 06 17:54:08 2012 +0200
@@ -34,10 +34,9 @@
 from rhodecode.lib.utils import action_logger
 from rhodecode.lib.vcs.backends.base import EmptyChangeset
 from rhodecode.lib.compat import json
-from rhodecode.model.db import Repository, User
+from rhodecode.lib.exceptions import HTTPLockedRC
 from rhodecode.lib.utils2 import safe_str
-from rhodecode.lib.exceptions import HTTPLockedRC
-
+from rhodecode.model.db import Repository, User
 
 def _get_scm_size(alias, root_path):
 
@@ -330,7 +329,12 @@
     # fix if it's not a bare repo
     if repo_path.endswith('.git'):
         repo_path = repo_path[:-4]
+
     repo = Repository.get_by_full_path(repo_path)
+    if not repo:
+        raise OSError('Repository %s not found in database'
+                      % (safe_str(repo_path)))
+
     _hooks = dict(baseui.configitems('hooks')) or {}
 
     extras = json.loads(env['RHODECODE_EXTRAS'])