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 * config file syntax gets checked upfront, and much more thoroughly
* if your requirements are still too complex, you can split up the config * if your requirements are still too complex, you can split up the config
file and delegate authority over parts of it 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 * easier to sync gitweb (http) authorisation with gitolite's access config
* more comprehensive logging [aka: management does not think "blame" is just * more comprehensive logging [aka: management does not think "blame" is just
a synonym for "annotate" :-)] a synonym for "annotate" :-)]

View file

@ -130,13 +130,13 @@ repo @oss_repos
repo linux perl repo linux perl
R = gitweb R = gitweb
# GITWEB DESCRIPTION LINE # REPO OWNER/DESCRIPTION LINE FOR GITWEB
# syntax: # syntax, one of:
# reponame = "some description string in double quotes" # 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 # 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 # 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" 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 Note that gitolite does **not** install or configure gitweb/daemon -- that is
a one-time setup you must do separately. All this does 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 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 * for gitweb, add the repo (plus owner name, if given) to the list of
(see the config file variable `$PROJECTS_LIST`, which should have the same projects to be served by gitweb (see the config file variable
value you specified for `$projects_list` when setting up gitweb) `$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` * put the description, if given, in `$repo/description`
The "compile" script will keep these files consistent with the config settings The "compile" script will keep these files consistent with the config settings

View file

@ -204,6 +204,10 @@ file:
reponame = "one line of description" 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" To enable access to one or more repos via git daemon, just give "read"
permissions to the special username `daemon`. permissions to the special username `daemon`.

View file

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