gitprep / templates / fork.html.ep /
36025d0 8 years ago
1 contributor
34 lines | 0.776kb
<%
  # 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 (my $e = $@) {
      $self->reply->exception('Internal Error');
      app->log->error(url_for . ": $e");
    }
    else {
      flash(message => "Repository is forked from /$user/$project.");
      $self->redirect_to("/$current_user/$project");
    }
    return;
  }
%>