Show More
@@ -207,15 +207,17 def log_push_action(ui, repo, **kwargs): | |||
|
207 | 207 | repository = extras['repository'] |
|
208 | 208 | scm = extras['scm'] |
|
209 | 209 | make_lock = extras['make_lock'] |
|
210 | action = extras['action'] | |
|
210 | 211 | elif 'username' in rc_extras: |
|
211 | 212 | username = rc_extras['username'] |
|
212 | 213 | repository = rc_extras['repository'] |
|
213 | 214 | scm = rc_extras['scm'] |
|
214 | 215 | make_lock = rc_extras['make_lock'] |
|
216 | action = extras['action'] | |
|
215 | 217 | else: |
|
216 | 218 | raise Exception('Missing data in repo.ui and os.environ') |
|
217 | 219 | |
|
218 |
action = |
|
|
220 | action = action + ':%s' | |
|
219 | 221 | |
|
220 | 222 | if scm == 'hg': |
|
221 | 223 | node = kwargs['node'] |
@@ -44,13 +44,14 from rhodecode.lib.vcs.backends.base imp | |||
|
44 | 44 | |
|
45 | 45 | from rhodecode import BACKENDS |
|
46 | 46 | from rhodecode.lib import helpers as h |
|
47 | from rhodecode.lib.utils2 import safe_str, safe_unicode | |
|
47 | from rhodecode.lib.utils2 import safe_str, safe_unicode, get_server_url | |
|
48 | 48 | from rhodecode.lib.auth import HasRepoPermissionAny, HasReposGroupPermissionAny |
|
49 | 49 | from rhodecode.lib.utils import get_filesystem_repos, make_ui, \ |
|
50 | 50 | action_logger, REMOVED_REPO_PAT |
|
51 | 51 | from rhodecode.model import BaseModel |
|
52 | 52 | from rhodecode.model.db import Repository, RhodeCodeUi, CacheInvalidation, \ |
|
53 | 53 | UserFollowing, UserLog, User, RepoGroup, PullRequest |
|
54 | from rhodecode.lib.hooks import log_push_action | |
|
54 | 55 | |
|
55 | 56 | log = logging.getLogger(__name__) |
|
56 | 57 | |
@@ -402,6 +403,31 class ScmModel(BaseModel): | |||
|
402 | 403 | self.sa.add(repo) |
|
403 | 404 | return repo |
|
404 | 405 | |
|
406 | def _handle_push(self, repo, username, action, repo_name, repo_scm, revisions): | |
|
407 | from rhodecode import CONFIG | |
|
408 | from rhodecode.lib.base import _get_ip_addr | |
|
409 | from pylons import request | |
|
410 | environ = request.environ | |
|
411 | ||
|
412 | #trigger push hook | |
|
413 | extras = { | |
|
414 | 'ip': _get_ip_addr(environ), | |
|
415 | 'username': username, | |
|
416 | 'action': 'push_local', | |
|
417 | 'repository': repo_name, | |
|
418 | 'scm': repo_scm, | |
|
419 | 'config': CONFIG['__file__'], | |
|
420 | 'server_url': get_server_url(environ), | |
|
421 | 'make_lock': None, | |
|
422 | 'locked_by': [None, None] | |
|
423 | } | |
|
424 | _scm_repo = repo._repo | |
|
425 | repo.inject_ui(**extras) | |
|
426 | if repo_scm == 'hg': | |
|
427 | log_push_action(_scm_repo.ui, _scm_repo, node=revisions[0]) | |
|
428 | elif repo_scm == 'git': | |
|
429 | log_push_action(_scm_repo.ui, _scm_repo, _git_revs=revisions) | |
|
430 | ||
|
405 | 431 | def pull_changes(self, repo, username): |
|
406 | 432 | dbrepo = self.__get_repo(repo) |
|
407 | 433 | clone_uri = dbrepo.clone_uri |
@@ -409,26 +435,13 class ScmModel(BaseModel): | |||
|
409 | 435 | raise Exception("This repository doesn't have a clone uri") |
|
410 | 436 | |
|
411 | 437 | repo = dbrepo.scm_instance |
|
412 | from rhodecode import CONFIG | |
|
438 | repo_name = dbrepo.repo_name | |
|
413 | 439 | try: |
|
414 | extras = { | |
|
415 | 'ip': '', | |
|
416 | 'username': username, | |
|
417 | 'action': 'push_remote', | |
|
418 | 'repository': dbrepo.repo_name, | |
|
419 | 'scm': repo.alias, | |
|
420 | 'config': CONFIG['__file__'], | |
|
421 | 'make_lock': None, | |
|
422 | 'locked_by': [None, None] | |
|
423 | } | |
|
424 | ||
|
425 | Repository.inject_ui(repo, extras=extras) | |
|
426 | ||
|
427 | 440 | if repo.alias == 'git': |
|
428 | 441 | repo.fetch(clone_uri) |
|
429 | 442 | else: |
|
430 | 443 | repo.pull(clone_uri) |
|
431 |
self.mark_for_invalidation( |
|
|
444 | self.mark_for_invalidation(repo_name) | |
|
432 | 445 | except: |
|
433 | 446 | log.error(traceback.format_exc()) |
|
434 | 447 | raise |
@@ -441,7 +454,6 class ScmModel(BaseModel): | |||
|
441 | 454 | :param repo: SCM instance |
|
442 | 455 | |
|
443 | 456 | """ |
|
444 | ||
|
445 | 457 | if repo.alias == 'hg': |
|
446 | 458 | from rhodecode.lib.vcs.backends.hg import \ |
|
447 | 459 | MercurialInMemoryChangeset as IMC |
@@ -463,9 +475,13 class ScmModel(BaseModel): | |||
|
463 | 475 | author=author, |
|
464 | 476 | parents=[cs], branch=cs.branch) |
|
465 | 477 | |
|
466 | action = 'push_local:%s' % tip.raw_id | |
|
467 | action_logger(user, action, repo_name) | |
|
468 | 478 | self.mark_for_invalidation(repo_name) |
|
479 | self._handle_push(repo, | |
|
480 | username=user.username, | |
|
481 | action='push_local', | |
|
482 | repo_name=repo_name, | |
|
483 | repo_scm=repo.alias, | |
|
484 | revisions=[tip.raw_id]) | |
|
469 | 485 | return tip |
|
470 | 486 | |
|
471 | 487 | def create_node(self, repo, repo_name, cs, user, author, message, content, |
@@ -502,9 +518,13 class ScmModel(BaseModel): | |||
|
502 | 518 | author=author, |
|
503 | 519 | parents=parents, branch=cs.branch) |
|
504 | 520 | |
|
505 | action = 'push_local:%s' % tip.raw_id | |
|
506 | action_logger(user, action, repo_name) | |
|
507 | 521 | self.mark_for_invalidation(repo_name) |
|
522 | self._handle_push(repo, | |
|
523 | username=user.username, | |
|
524 | action='push_local', | |
|
525 | repo_name=repo_name, | |
|
526 | repo_scm=repo.alias, | |
|
527 | revisions=[tip.raw_id]) | |
|
508 | 528 | return tip |
|
509 | 529 | |
|
510 | 530 | def get_nodes(self, repo_name, revision, root_path='/', flat=True): |
General Comments 0
You need to be logged in to leave comments.
Login now