Merge branch 'gitweb-owner'

This commit is contained in:
Sitaram Chamarty 2009-11-27 13:52:34 +05:30
commit 5696b13f62
5 changed files with 38 additions and 54 deletions

View file

@ -73,7 +73,7 @@ detail [here][gsdiff].
* config file syntax gets checked upfront, and much more thoroughly
* if your requirements are still too complex, you can split up the config
file and delegate authority over parts of it
* easier to specify gitweb "description" and gitweb/daemon access
* easier to specify gitweb owner, description and gitweb/daemon access
* easier to sync gitweb (http) authorisation with gitolite's access config
* more comprehensive logging [aka: management does not think "blame" is just
a synonym for "annotate" :-)]

View file

@ -130,13 +130,13 @@ repo @oss_repos
repo linux perl
R = gitweb
# GITWEB DESCRIPTION LINE
# REPO OWNER/DESCRIPTION LINE FOR GITWEB
# syntax:
# syntax, one of:
# reponame = "some description string in double quotes"
# reponame "owner name" = "some description string in double quotes"
# note: setting a description also gives gitweb access; you do not have to
# give gitweb access as described above if you're specifying a description
gitolite = "fast, secure, access control for git in a corporate environment"
gitolite "Sitaram Chamarty" = "fast, secure, access control for git in a corporate environment"

View file

@ -57,13 +57,18 @@ so you may as well use that method and kill two birds with one stone, like so:
gitolite = "fast, secure, access control for git in a corporate environment"
You can also specify an owner for gitweb to show, if you like:
gitolite "Sitaram Chamarty" = "fast, secure, access control for git in a corporate environment"
Note that gitolite does **not** install or configure gitweb/daemon -- that is
a one-time setup you must do separately. All this does is:
* for daemon, create the file `git-daemon-export-ok` in the repository
* for gitweb, add the repo to the list of projects to be served by gitweb
(see the config file variable `$PROJECTS_LIST`, which should have the same
value you specified for `$projects_list` when setting up gitweb)
* for gitweb, add the repo (plus owner name, if given) to the list of
projects to be served by gitweb (see the config file variable
`$PROJECTS_LIST`, which should have the same value you specified for
`$projects_list` when setting up gitweb)
* put the description, if given, in `$repo/description`
The "compile" script will keep these files consistent with the config settings

View file

@ -204,6 +204,10 @@ file:
reponame = "one line of description"
You can also specify an "owner":
reponame "owner name" = "one line of description"
To enable access to one or more repos via git daemon, just give "read"
permissions to the special username `daemon`.

View file

@ -107,8 +107,9 @@ my %rurp_seen = ();
# catch usernames<->pubkeys mismatches; search for "lint" below
my %user_list = ();
# gitweb descriptions, plain text, keyed by repo
# gitweb descriptions and owners; plain text, keyed by "$repo.git"
my %desc = ();
my %owner = ();
# set the umask before creating any files
umask($REPO_UMASK);
@ -253,14 +254,18 @@ sub parse_conf_file
}
}
}
# very simple syntax for the gitweb description of repo
elsif (/^(\S+) = "(.*)"$/)
# very simple syntax for the gitweb description of repo; one of:
# reponame = "some description string"
# reponame "owner name" = "some description string"
elsif (/^(\S+)(?: "(.*?)")? = "(.*)"$/)
{
my ($repo, $desc) = ($1, $2);
my ($repo, $owner, $desc) = ($1, $2, $3);
die "$ABRT bad repo name $repo\n" unless $repo =~ $REPONAME_PATT;
die "$WARN $fragment attempting to set description for $repo\n" if
$fragment ne 'master' and $fragment ne $repo and ($groups{"\@$fragment"}{$repo} || '') ne 'master';
$desc{$repo} = $desc;
$desc{"$repo.git"} = $desc;
$owner =~ s/ /+/g if $owner; # gitweb/INSTALL wants more, but meh...!
$owner{"$repo.git"} = $owner || '';
}
else
{
@ -360,67 +365,37 @@ warn "\n\t\t***** WARNING *****\n" .
wrap_chdir("$repo_base_abs");
# get the current project list; note that the file may not yet exist if no
# gitweb access has been specified so far
my %projlist = ();
if (-f $PROJECTS_LIST) {
my $projlist_fh = wrap_open( "<", $PROJECTS_LIST);
while(<$projlist_fh>) {
chomp;
$projlist{$_} = 1;
}
close $projlist_fh;
}
my $projlist_changed = 0;
# daemons first...
for my $repo (sort keys %repos) {
my $export_ok = "$repo.git/git-daemon-export-ok";
if ($repos{$repo}{'R'}{'daemon'}) {
unless (-f $export_ok) {
system("touch $export_ok");
print "daemon add $repo.git\n";
}
system("touch $export_ok");
} else {
if (-f $export_ok) {
unlink($export_ok);
print "daemon del $repo.git\n";
}
unlink($export_ok);
}
}
my %projlist = ();
# ...then gitwebs
for my $repo (sort keys %repos) {
my $desc_file = "$repo.git/description";
# note: having a description also counts as enabling gitweb
if ($repos{$repo}{'R'}{'gitweb'} or $desc{$repo}) {
unless ($projlist{"$repo.git"}) {
# not in the old list; add it to the new one
$projlist{"$repo.git"} = 1;
$projlist_changed = 1;
print "gitweb add $repo.git\n";
}
if ($repos{$repo}{'R'}{'gitweb'} or $desc{"$repo.git"}) {
$projlist{"$repo.git"} = 1;
# add the description file; no messages to user or error checking :)
$desc{$repo} and open(DESC, ">", $desc_file) and print DESC "$desc{$repo}\n" and close DESC;
$desc{"$repo.git"} and open(DESC, ">", $desc_file) and print DESC $desc{"$repo.git"} . "\n" and close DESC;
} else {
if ($projlist{"$repo.git"}) {
# delete it from new list
delete $projlist{"$repo.git"};
$projlist_changed = 1;
print "gitweb del $repo.git\n";
}
# delete the description file; no messages to user or error checking :)
unlink $desc_file;
}
}
# has there been a change in the gitweb projects list?
if ($projlist_changed) {
print "updating gitweb project list $PROJECTS_LIST\n";
my $projlist_fh = wrap_open( ">", $PROJECTS_LIST);
print $projlist_fh join("\n", sort keys %projlist), "\n" if %projlist;
close $projlist_fh;
# update the project list
my $projlist_fh = wrap_open( ">", $PROJECTS_LIST);
for my $proj (sort keys %projlist) {
print $projlist_fh "$proj" . ( $owner{$proj} ? " $owner{$proj}" : "" ) . "\n";
}
close $projlist_fh;
# ----------------------------------------------------------------------------
# "compile" ssh authorized_keys