Show More
@@ -194,8 +194,8 b' class SimpleGit(BaseVCSController):' | |||||
194 | log.debug('Repository path is %s' % repo_path) |
|
194 | log.debug('Repository path is %s' % repo_path) | |
195 |
|
195 | |||
196 | baseui = make_ui('db') |
|
196 | baseui = make_ui('db') | |
197 | for k, v in extras.items(): |
|
197 | self.__inject_extras(repo_path, baseui, extras) | |
198 | baseui.setconfig('rhodecode_extras', k, v) |
|
198 | ||
199 |
|
199 | |||
200 | try: |
|
200 | try: | |
201 | # invalidate cache on push |
|
201 | # invalidate cache on push | |
@@ -265,22 +265,36 b' class SimpleGit(BaseVCSController):' | |||||
265 | return op |
|
265 | return op | |
266 |
|
266 | |||
267 | def _handle_githooks(self, action, baseui, environ): |
|
267 | def _handle_githooks(self, action, baseui, environ): | |
268 |
|
||||
269 | from rhodecode.lib.hooks import log_pull_action, log_push_action |
|
268 | from rhodecode.lib.hooks import log_pull_action, log_push_action | |
270 | service = environ['QUERY_STRING'].split('=') |
|
269 | service = environ['QUERY_STRING'].split('=') | |
271 | if len(service) < 2: |
|
270 | if len(service) < 2: | |
272 | return |
|
271 | return | |
273 |
|
272 | |||
274 | class cont(object): |
|
273 | from rhodecode.model.db import Repository | |
275 | pass |
|
274 | _repo = Repository.get_by_repo_name(repo_name) | |
276 |
|
275 | _repo = _repo.scm_instance | ||
277 | repo = cont() |
|
276 | _repo._repo.ui = baseui | |
278 | setattr(repo, 'ui', baseui) |
|
|||
279 |
|
277 | |||
280 | push_hook = 'pretxnchangegroup.push_logger' |
|
278 | push_hook = 'pretxnchangegroup.push_logger' | |
281 | pull_hook = 'preoutgoing.pull_logger' |
|
279 | pull_hook = 'preoutgoing.pull_logger' | |
282 | _hooks = dict(baseui.configitems('hooks')) or {} |
|
280 | _hooks = dict(baseui.configitems('hooks')) or {} | |
283 | if action == 'push' and _hooks.get(push_hook): |
|
281 | if action == 'push' and _hooks.get(push_hook): | |
284 | log_push_action(ui=baseui, repo=repo) |
|
282 | log_push_action(ui=baseui, repo=repo._repo) | |
285 | elif action == 'pull' and _hooks.get(pull_hook): |
|
283 | elif action == 'pull' and _hooks.get(pull_hook): | |
286 | log_pull_action(ui=baseui, repo=repo) |
|
284 | log_pull_action(ui=baseui, repo=repo._repo) | |
|
285 | ||||
|
286 | def __inject_extras(self, repo_path, baseui, extras={}): | |||
|
287 | """ | |||
|
288 | Injects some extra params into baseui instance | |||
|
289 | ||||
|
290 | :param baseui: baseui instance | |||
|
291 | :param extras: dict with extra params to put into baseui | |||
|
292 | """ | |||
|
293 | ||||
|
294 | # make our hgweb quiet so it doesn't print output | |||
|
295 | baseui.setconfig('ui', 'quiet', 'true') | |||
|
296 | ||||
|
297 | #inject some additional parameters that will be available in ui | |||
|
298 | #for hooks | |||
|
299 | for k, v in extras.items(): | |||
|
300 | baseui.setconfig('rhodecode_extras', k, v) |
@@ -47,6 +47,15 b' class GitRepository(BaseRepository):' | |||||
47 |
|
47 | |||
48 | self.path = abspath(repo_path) |
|
48 | self.path = abspath(repo_path) | |
49 | self._repo = self._get_repo(create, src_url, update_after_clone, bare) |
|
49 | self._repo = self._get_repo(create, src_url, update_after_clone, bare) | |
|
50 | #temporary set that to now at later we will move it to constructor | |||
|
51 | baseui = None | |||
|
52 | if baseui is None: | |||
|
53 | from mercurial.ui import ui | |||
|
54 | baseui = ui() | |||
|
55 | # patch the instance of GitRepo with an "FAKE" ui object to add | |||
|
56 | # compatibility layer with Mercurial | |||
|
57 | setattr(self._repo, 'ui', baseui) | |||
|
58 | ||||
50 | try: |
|
59 | try: | |
51 | self.head = self._repo.head() |
|
60 | self.head = self._repo.head() | |
52 | except KeyError: |
|
61 | except KeyError: | |
@@ -471,6 +480,17 b' class GitRepository(BaseRepository):' | |||||
471 | # If error occurs run_git_command raises RepositoryError already |
|
480 | # If error occurs run_git_command raises RepositoryError already | |
472 | self.run_git_command(cmd) |
|
481 | self.run_git_command(cmd) | |
473 |
|
482 | |||
|
483 | def pull(self, url): | |||
|
484 | """ | |||
|
485 | Tries to pull changes from external location. | |||
|
486 | """ | |||
|
487 | url = self._get_url(url) | |||
|
488 | cmd = ['pull'] | |||
|
489 | cmd.append("--ff-only") | |||
|
490 | cmd = ' '.join(cmd) | |||
|
491 | # If error occurs run_git_command raises RepositoryError already | |||
|
492 | self.run_git_command(cmd) | |||
|
493 | ||||
474 | @LazyProperty |
|
494 | @LazyProperty | |
475 | def workdir(self): |
|
495 | def workdir(self): | |
476 | """ |
|
496 | """ |
@@ -351,7 +351,7 b' class ScmModel(BaseModel):' | |||||
351 | 'scm': repo.alias, |
|
351 | 'scm': repo.alias, | |
352 | } |
|
352 | } | |
353 |
|
353 | |||
354 | #inject ui extra param to log this action via push logger |
|
354 | # inject ui extra param to log this action via push logger | |
355 | for k, v in extras.items(): |
|
355 | for k, v in extras.items(): | |
356 | repo._repo.ui.setconfig('rhodecode_extras', k, v) |
|
356 | repo._repo.ui.setconfig('rhodecode_extras', k, v) | |
357 |
|
357 |
General Comments 0
You need to be logged in to leave comments.
Login now