Mercurial > kallithea
comparison 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 |
comparison
equal
deleted
inserted
replaced
2715:298bac3757a7 | 2716:4c71667160e5 |
---|---|
201 yield inner_scm | 201 yield inner_scm |
202 | 202 |
203 return _get_repos(path) | 203 return _get_repos(path) |
204 | 204 |
205 | 205 |
206 def is_valid_repo(repo_name, base_path): | 206 def is_valid_repo(repo_name, base_path, scm=None): |
207 """ | 207 """ |
208 Returns True if given path is a valid repository False otherwise | 208 Returns True if given path is a valid repository False otherwise. |
209 If scm param is given also compare if given scm is the same as expected | |
210 from scm parameter | |
209 | 211 |
210 :param repo_name: | 212 :param repo_name: |
211 :param base_path: | 213 :param base_path: |
214 :param scm: | |
212 | 215 |
213 :return True: if given path is a valid repository | 216 :return True: if given path is a valid repository |
214 """ | 217 """ |
215 full_path = os.path.join(safe_str(base_path), safe_str(repo_name)) | 218 full_path = os.path.join(safe_str(base_path), safe_str(repo_name)) |
216 | 219 |
217 try: | 220 try: |
218 get_scm(full_path) | 221 scm_ = get_scm(full_path) |
222 if scm: | |
223 return scm_[0] == scm | |
219 return True | 224 return True |
220 except VCSError: | 225 except VCSError: |
221 return False | 226 return False |
222 | 227 |
223 | 228 |