gitprep / templates / fork.html.ep /
7233306 10 years ago
1 contributor
34 lines | 0.778kb
<%
  # API
  my $api = gitprep_api;
  
  # Paramters
  my $user = param('user');
  my $project = param('project');
  my $current_user = session('user');
  
  # Can fork?
  unless ($api->logined) {
    $self->redirect_to('/');
    return;
  }
  
  # Repository is already exists
  if (app->manager->exists_project($current_user, $project)) {
    $self->redirect_to("/$current_user/$project");
    return;
  }
  # Fork
  else {
    eval { app->manager->fork_project($current_user, $user, $project) };
    if ($@) {
      $self->render_exception('Internal Error');
      app->log->error("/$user/$project/fork: $@");
    }
    else {
      flash(message => "Repository is forked from /$user/$project.");
      $self->redirect_to("/$current_user/$project");
    }
    return;
  }
%>