From fa65d719a83fa33d8f8d95abdf4c9013dc1effc4 Mon Sep 17 00:00:00 2001 From: Teemu Matilainen Date: Thu, 4 Feb 2010 23:40:13 +0200 Subject: [PATCH] Enable setting desription for wildrepos Allow users to set and display description (for gitweb) for their own wildcard repositories using ssh commands: setdesc getdesc Signed-off-by: Teemu Matilainen --- src/gitolite.pm | 20 ++++++++++++++++++++ src/gl-auth-command | 6 +++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/gitolite.pm b/src/gitolite.pm index a73f255..eb70dec 100644 --- a/src/gitolite.pm +++ b/src/gitolite.pm @@ -180,6 +180,26 @@ sub get_set_perms } } +# ---------------------------------------------------------------------------- +# getdesc and setdesc +# ---------------------------------------------------------------------------- + +sub get_set_desc +{ + my($repo_base_abs, $repo, $verb, $user) = @_; + my ($creater, $dummy, $dummy2) = &repo_rights($repo_base_abs, $repo, ""); + die "$repo doesnt exist or is not yours\n" unless $user eq $creater; + wrap_chdir("$repo_base_abs"); + wrap_chdir("$repo.git"); + if ($verb eq 'getdesc') { + system("cat", "description") if -f "description"; + } else { + system("cat > description"); + print "New description is:\n"; + system("cat", "description"); + } +} + # ---------------------------------------------------------------------------- # parse the compiled acl # ---------------------------------------------------------------------------- diff --git a/src/gl-auth-command b/src/gl-auth-command index 26fbf71..253ccad 100755 --- a/src/gl-auth-command +++ b/src/gl-auth-command @@ -86,7 +86,7 @@ my $repo_base_abs = ( $REPO_BASE =~ m(^/) ? $REPO_BASE : "$ENV{HOME}/$REPO_BASE" # get and set perms for actual repo created by wildcard-autoviv # ---------------------------------------------------------------------------- -my $CUSTOM_COMMANDS=qr/^\s*(expand|getperms|setperms)\s/; +my $CUSTOM_COMMANDS=qr/^\s*(expand|(get|set)(perms|desc))\s/; # note that all the subs called here chdir somewhere else and do not come # back; they all blithely take advantage of the fact that processing custom @@ -98,6 +98,10 @@ if ($cmd =~ $CUSTOM_COMMANDS) { # with an actual reponame, you can "getperms" or "setperms" get_set_perms($repo_base_abs, $repo, $verb, $user); } + elsif ($repo =~ $REPONAME_PATT and $verb =~ /(get|set)desc/) { + # with an actual reponame, you can "getdesc" or "setdesc" + get_set_desc($repo_base_abs, $repo, $verb, $user); + } elsif ($verb eq 'expand') { # with a wildcard, you can "expand" it to see what repos actually match die "$repo has invalid characters" unless "x$repo" =~ $REPOPATT_PATT;