From 1c85bd91619bf6e3e7e90479f570a8618fcb1730 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Wed, 23 Jul 2008 17:56:31 +0200 Subject: [PATCH] Git::RepoCGI: Introduce $mirror and $push configuration variables --- cgi/Git/RepoCGI.pm | 2 ++ cgi/regproj.cgi | 69 ++++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 58 insertions(+), 13 deletions(-) diff --git a/cgi/Git/RepoCGI.pm b/cgi/Git/RepoCGI.pm index 7a6a764..a4561da 100644 --- a/cgi/Git/RepoCGI.pm +++ b/cgi/Git/RepoCGI.pm @@ -15,6 +15,8 @@ $Git::RepoCGI::jurisdiction = "Czech Republic"; # legal jurisdiction of the site $Git::RepoCGI::giroccourl = "$Git::RepoCGI::gitweburl/repo.git"; # URL of gitweb of this Girocco instance (set as undef if you're not nice to the community) $Git::RepoCGI::mob = "mob"; # set to undef to disable the special 'mob' user $Git::RepoCGI::moburl = "/mob.html"; # URL of the explanation of the mob user +$Git::RepoCGI::mirror = 1; # enable mirroring mode +$Git::RepoCGI::push = 1; # enable push mode ### Administrativa diff --git a/cgi/regproj.cgi b/cgi/regproj.cgi index fb0a399..dfeba91 100755 --- a/cgi/regproj.cgi +++ b/cgi/regproj.cgi @@ -33,9 +33,11 @@ if ($cgi->param('mode')) { my $proj = Git::RepoCGI::Project->ghost($name, $mirror); if ($proj->cgi_fill($repo)) { if ($mirror) { + $Git::RepoCGI::mirror or $repo->err("Mirroring mode is not enabled at this site."); $proj->premirror; print "

Initiated mirroring. You will be notified about the result by mail.

\n"; } else { + $Git::RepoCGI::push or $repo->err("Push mode is not enabled at this site."); $proj->conjure; print < @@ -61,37 +63,80 @@ EOT } } -print <Here you can register a project. -It can be hosted in two modes: mirror mode and push mode. -In the mirror mode, our dedicated git monkeys will check another repository at a given URL every hour and mirror any new updates. -In the push mode, registered users with appropriate permissions will be able to push to the repository. +my $mirror_mode = { + name => 'mirror', + desc => 'our dedicated git monkeys will check another repository at a given URL every hour and mirror any new updates', + pwpurp => 'mirroring URL' +}; +my $push_mode = { + name => 'push', + desc => 'registered users with appropriate permissions will be able to push to the repository', + pwpurp => 'list of users allowed to push' +}; + +my $me = $Git::RepoCGI::mirror ? $mirror_mode : undef; +my ($me, $pe) = $Git::RepoCGI::push ? $push_mode : undef; +if ($me and $pe) { + print <At this site, you can host a project in one of two modes: $me->{name} mode and $pe->{name} mode. +In the $me->{name} mode, $me->{desc}. +In the $pe->{name} mode, $pe->{desc}. You currently cannot switch freely between those two modes; if you want to switch from mirroring to push mode, just delete and recreate the project. If you want to switch the other way, please contact the administrator.

+EOT +} else { + my $mode = $me ? $me : $pe; + print "

This site will host your project in a $mode->{name} mode: $mode->{desc}.

\n"; +} + +my @pwpurp = (); +push @pwpurp, $me->{pwpurp} if $me; +push @pwpurp, $pe->{pwpurp} if $pe; +my $pwpurp = join(', ', @pwpurp); + +print <You will need the admin password to adjust the project settings later -(mirroring URL, list of users allowed to push, project description, ...). +($pwpurp, project description, ...). Use the project name (without .git) as the username when asked by the browser.

EOT + unless ($name =~ m#/#) { print <Note that if your project is a fork of an existing project (this does not mean anything socially bad), please instead go to the project's gitweb page and click the 'fork' link in the top bar. This way, all of us will save bandwidth and more importantly, your project will be properly categorized. +EOT + $me and print < EOT } else { - my $xname = $name; $xname =~ s#/$#.git#; + my $xname = $name; $xname =~ s#/$#.git#; # + my ($pushnote1, $pushnote2); + $pushnote1 = " and you will need to push only the data you created, not the whole project" if $pe; + $pushnote2 = "(That will be done automagically, you do not need to specify any extra arguments during the push.)" if $pe; print <Great, your project will be created as a subproject of the '$xname' project. -This means that it will be properly categorized and you will need to push only -the data you created, not the whole project. (That will be done automagically, -you do not need to specify any extra arguments during the push.)

+This means that it will be properly categorized$pushnote1. $pushnote2

+EOT +} + +my $modechooser; +my $mirrorentry = 'Repository URL: '; +if ($me and $pe) { + $modechooser = <Hosting mode:

    +
  • Mirror mode. $mirrorentry
  • +
  • Push mode.
EOT +} else { + $modechooser = ''; + $me and $modechooser .= "

$mirrorentry

"; } + print <By submitting this form, you are confirming that the repository contains only free software and redistributing it does not violate any law of $Git::RepoCGI::jurisdiction. Read more details @@ -102,9 +147,7 @@ about the hosting and terms and conditions.

Admin password:

Admin password (retype):

E-mail contact:

-

Hosting mode:

    -
  • Mirror mode. Repository URL:
  • -
  • Push mode.
+$modechooser

Description:

Homepage URL:

README (HTML, lt 8kb):

-- 2.11.4.GIT