Commits

Marcin Kuzminski committed eac0d61

fixed repo_create hooks for forks

Comments (0)

Files changed (2)

rhodecode/lib/celerylib/tasks.py

 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
 
 
     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']
     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)
 
     # 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

rhodecode/model/repo.py

                 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())