# HG changeset patch # User Marcin Kuzminski # Date 2012-04-12 22:30:06 # Node ID eac0d619478392c611ac819d56df84b999484a64 # Parent 79e4d6b9c1f0535c21db325e3ff9b3d140ceaade fixed repo_create hooks for forks diff --git a/rhodecode/lib/celerylib/tasks.py b/rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py +++ b/rhodecode/lib/celerylib/tasks.py @@ -47,6 +47,7 @@ from rhodecode.lib.helpers import person from rhodecode.lib.rcmail.smtp_mailer import SmtpMailer from rhodecode.lib.utils import add_cache, action_logger from rhodecode.lib.compat import json, OrderedDict +from rhodecode.lib.hooks import log_create_repository from rhodecode.model.db import Statistics, Repository, User @@ -372,7 +373,8 @@ def create_repo_fork(form_data, cur_user base_path = Repository.base_path() - RepoModel(DBS).create(form_data, cur_user, just_db=True, fork=True) + fork_repo = RepoModel(DBS).create(form_data, cur_user, + just_db=True, fork=True) alias = form_data['repo_type'] org_repo_name = form_data['org_path'] @@ -387,6 +389,8 @@ def create_repo_fork(form_data, cur_user backend(safe_str(destination_fork_path), create=True, src_url=safe_str(source_repo_path), update_after_clone=update_after_clone) + log_create_repository(fork_repo.get_dict(), created_by=cur_user.username) + action_logger(cur_user, 'user_forked_repo:%s' % fork_name, org_repo_name, '', DBS) @@ -395,6 +399,7 @@ def create_repo_fork(form_data, cur_user # finally commit at latest possible stage DBS.commit() + def __get_codes_stats(repo_name): from rhodecode.config.conf import LANGUAGES_EXTENSIONS_MAP repo = Repository.get_by_repo_name(repo_name).scm_instance diff --git a/rhodecode/model/repo.py b/rhodecode/model/repo.py --- a/rhodecode/model/repo.py +++ b/rhodecode/model/repo.py @@ -286,12 +286,12 @@ class RepoModel(BaseModel): self.__create_repo(repo_name, form_data['repo_type'], form_data['repo_group'], form_data['clone_uri']) + log_create_repository(new_repo.get_dict(), + created_by=cur_user.username) # now automatically start following this repository as owner ScmModel(self.sa).toggle_following_repo(new_repo.repo_id, cur_user.user_id) - log_create_repository(new_repo.get_dict(), - created_by=cur_user.username) return new_repo except: log.error(traceback.format_exc())