1 contributor
<%
# API
my $api = gitprep_api;
# Parameters
my $user_id = param('user');
my $project_id = param('project');
my $session_user_row_id = session('user_row_id');
my $session_user = app->dbi->model('user')->select(
where => {row_id => $session_user_row_id}
)->one;
# Can fork?
unless ($api->logined) {
$self->redirect_to('/');
return;
}
# Repository is already exists
if (app->manager->exists_project($session_user->{id}, $project_id)) {
$self->redirect_to("/$session_user->{id}/$project_id");
return;
}
# Fork
else {
eval { app->manager->fork_project($session_user->{id}, $user_id, $project_id) };
if (my $e = $@) {
$self->reply->exception('Internal Error');
app->log->error(url_for . ": $e");
}
else {
flash(message => "Repository is forked from /$user_id/$project_id.");
$self->redirect_to("/$session_user->{id}/$project_id");
}
return;
}
%>