diff rhodecode/lib/utils.py @ 2716:4c71667160e5 beta

use os.environ as a fallback for getting special info from hooks, this will allow calling RhodeCode hooks from outside the system eg. via SSH - also verify repo if it's a correct VCS throw 404 error otherwise
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 15 Aug 2012 00:22:53 +0200
parents 73cfc54c87d5
children dd240b2b7a12
line wrap: on
line diff
--- a/rhodecode/lib/utils.py	Tue Aug 14 01:16:29 2012 +0200
+++ b/rhodecode/lib/utils.py	Wed Aug 15 00:22:53 2012 +0200
@@ -203,19 +203,24 @@
     return _get_repos(path)
 
 
-def is_valid_repo(repo_name, base_path):
+def is_valid_repo(repo_name, base_path, scm=None):
     """
-    Returns True if given path is a valid repository False otherwise
+    Returns True if given path is a valid repository False otherwise.
+    If scm param is given also compare if given scm is the same as expected 
+    from scm parameter
 
     :param repo_name:
     :param base_path:
+    :param scm:
 
     :return True: if given path is a valid repository
     """
     full_path = os.path.join(safe_str(base_path), safe_str(repo_name))
 
     try:
-        get_scm(full_path)
+        scm_ = get_scm(full_path)
+        if scm:
+            return scm_[0] == scm
         return True
     except VCSError:
         return False