Show More
@@ -157,12 +157,10 b' class ForksController(BaseRepoController' | |||||
157 | form_result = {} |
|
157 | form_result = {} | |
158 | try: |
|
158 | try: | |
159 | form_result = _form.to_python(dict(request.POST)) |
|
159 | form_result = _form.to_python(dict(request.POST)) | |
160 | # add org_path of repo so we can do a clone from it later |
|
|||
161 | form_result['org_path'] = c.repo_info.repo_name |
|
|||
162 |
|
160 | |||
163 | # create fork is done sometimes async on celery, db transaction |
|
161 | # create fork is done sometimes async on celery, db transaction | |
164 | # management is handled there. |
|
162 | # management is handled there. | |
165 | RepoModel().create_fork(form_result, self.rhodecode_user) |
|
163 | RepoModel().create_fork(form_result, self.rhodecode_user.user_id) | |
166 | h.flash(_('forked %s repository as %s') \ |
|
164 | h.flash(_('forked %s repository as %s') \ | |
167 | % (repo_name, form_result['repo_name']), |
|
165 | % (repo_name, form_result['repo_name']), | |
168 | category='success') |
|
166 | category='success') |
@@ -367,32 +367,46 b' def create_repo_fork(form_data, cur_user' | |||||
367 | :param cur_user: |
|
367 | :param cur_user: | |
368 | """ |
|
368 | """ | |
369 | from rhodecode.model.repo import RepoModel |
|
369 | from rhodecode.model.repo import RepoModel | |
|
370 | from rhodecode.model.user import UserModel | |||
370 |
|
371 | |||
371 | log = get_logger(create_repo_fork) |
|
372 | log = get_logger(create_repo_fork) | |
372 | DBS = get_session() |
|
373 | DBS = get_session() | |
373 |
|
374 | |||
374 | base_path = Repository.base_path() |
|
375 | base_path = Repository.base_path() | |
375 |
|
376 | cur_user = UserModel(DBS)._get_user(cur_user) | ||
376 | fork_repo = RepoModel(DBS).create(form_data, cur_user.user_id, |
|
|||
377 | just_db=True, fork=True) |
|
|||
378 |
|
377 | |||
379 | alias = form_data['repo_type'] |
|
|||
380 | org_repo_name = form_data['org_path'] |
|
|||
381 | fork_name = form_data['repo_name_full'] |
|
378 | fork_name = form_data['repo_name_full'] | |
|
379 | repo_type = form_data['repo_type'] | |||
|
380 | description = form_data['description'] | |||
|
381 | owner = cur_user | |||
|
382 | private = form_data['private'] | |||
|
383 | clone_uri = form_data.get('clone_uri') | |||
|
384 | repos_group = form_data['repo_group'] | |||
|
385 | landing_rev = form_data['landing_rev'] | |||
|
386 | copy_fork_permissions = form_data.get('copy_permissions') | |||
|
387 | fork_of = RepoModel(DBS)._get_repo(form_data.get('fork_parent_id')) | |||
|
388 | ||||
|
389 | fork_repo = RepoModel(DBS).create_repo( | |||
|
390 | fork_name, repo_type, description, owner, private, clone_uri, | |||
|
391 | repos_group, landing_rev, just_db=True, fork_of=fork_of, | |||
|
392 | copy_fork_permissions=copy_fork_permissions | |||
|
393 | ) | |||
|
394 | ||||
382 | update_after_clone = form_data['update_after_clone'] |
|
395 | update_after_clone = form_data['update_after_clone'] | |
383 | source_repo_path = os.path.join(base_path, org_repo_name) |
|
396 | ||
|
397 | source_repo_path = os.path.join(base_path, fork_of.repo_name) | |||
384 | destination_fork_path = os.path.join(base_path, fork_name) |
|
398 | destination_fork_path = os.path.join(base_path, fork_name) | |
385 |
|
399 | |||
386 | log.info('creating fork of %s as %s', source_repo_path, |
|
400 | log.info('creating fork of %s as %s', source_repo_path, | |
387 | destination_fork_path) |
|
401 | destination_fork_path) | |
388 |
backend = get_backend( |
|
402 | backend = get_backend(repo_type) | |
389 | backend(safe_str(destination_fork_path), create=True, |
|
403 | backend(safe_str(destination_fork_path), create=True, | |
390 | src_url=safe_str(source_repo_path), |
|
404 | src_url=safe_str(source_repo_path), | |
391 | update_after_clone=update_after_clone) |
|
405 | update_after_clone=update_after_clone) | |
392 | log_create_repository(fork_repo.get_dict(), created_by=cur_user.username) |
|
406 | log_create_repository(fork_repo.get_dict(), created_by=cur_user.username) | |
393 |
|
407 | |||
394 | action_logger(cur_user, 'user_forked_repo:%s' % fork_name, |
|
408 | action_logger(cur_user, 'user_forked_repo:%s' % fork_name, | |
395 |
|
|
409 | fork_of.repo_name, '', DBS) | |
396 |
|
410 | |||
397 | action_logger(cur_user, 'user_created_fork:%s' % fork_name, |
|
411 | action_logger(cur_user, 'user_created_fork:%s' % fork_name, | |
398 | fork_name, '', DBS) |
|
412 | fork_name, '', DBS) |
@@ -206,6 +206,10 b' class RepoModel(BaseModel):' | |||||
206 | private=False, clone_uri=None, repos_group=None, |
|
206 | private=False, clone_uri=None, repos_group=None, | |
207 | landing_rev='tip', just_db=False, fork_of=None, |
|
207 | landing_rev='tip', just_db=False, fork_of=None, | |
208 | copy_fork_permissions=False): |
|
208 | copy_fork_permissions=False): | |
|
209 | """ | |||
|
210 | Create repository | |||
|
211 | ||||
|
212 | """ | |||
209 | from rhodecode.model.scm import ScmModel |
|
213 | from rhodecode.model.scm import ScmModel | |
210 |
|
214 | |||
211 | owner = self._get_user(owner) |
|
215 | owner = self._get_user(owner) | |
@@ -292,6 +296,14 b' class RepoModel(BaseModel):' | |||||
292 | raise |
|
296 | raise | |
293 |
|
297 | |||
294 | def create(self, form_data, cur_user, just_db=False, fork=None): |
|
298 | def create(self, form_data, cur_user, just_db=False, fork=None): | |
|
299 | """ | |||
|
300 | Backward compatibility function, just a wrapper on top of create_repo | |||
|
301 | ||||
|
302 | :param form_data: | |||
|
303 | :param cur_user: | |||
|
304 | :param just_db: | |||
|
305 | :param fork: | |||
|
306 | """ | |||
295 |
|
307 | |||
296 | repo_name = form_data['repo_name_full'] |
|
308 | repo_name = form_data['repo_name_full'] | |
297 | repo_type = form_data['repo_type'] |
|
309 | repo_type = form_data['repo_type'] |
General Comments 0
You need to be logged in to leave comments.
Login now