git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/gitolite] Tell gitweb about repo owner via git-config
@ 2010-02-03  8:13 martin f. krafft
  2010-02-03 10:28 ` Sitaram Chamarty
  0 siblings, 1 reply; 2+ messages in thread
From: martin f. krafft @ 2010-02-03  8:13 UTC (permalink / raw)
  To: git; +Cc: martin f. krafft, Sitaram Chamarty

Gitolite uses projects.list to set the owners for gitweb's use.
Unfortunately, this does not work for gitweb setups that set
$projectroot to a directory, thus generating the list of
repositories on the fly.

This patch changes that: gitolite now writes the gitweb.owner
configuration variable for each repository (and properly cleans up after
itself if the owner is removed).

The patch causes gitolite not to write the owner to projects.list
anymore, as this would be redundant.

The owner also needs no longer be escaped, so this patch removes the
poor man's 's/ /+/g' escaping previously in place.

Note that I am not a Perl coder. Thus there are probably better ways to
implement this, but at least it works.

Cc: Sitaram Chamarty <sitaramc@gmail.com>
Signed-off-by: martin f. krafft <madduck@madduck.net>
---
 src/gl-compile-conf |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/gl-compile-conf b/src/gl-compile-conf
index e88819a..7cd5d2e 100755
--- a/src/gl-compile-conf
+++ b/src/gl-compile-conf
@@ -284,7 +284,6 @@ sub parse_conf_file
             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.git"} = $desc;
-            $owner =~ s/ /+/g if $owner;    # gitweb/INSTALL wants more, but meh...!
             $owner{"$repo.git"} = $owner || '';
         }
         else
@@ -414,16 +413,32 @@ for my $repo (sort keys %repos) {
         $projlist{"$repo.git"} = 1;
         # add the description file; no messages to user or error checking :)
         $desc{"$repo.git"} and open(DESC, ">", $desc_file) and print DESC $desc{"$repo.git"} . "\n" and close DESC;
+        if ($owner{"$repo.git"}) {
+            # set the repository owner
+            system("git --git-dir=$repo.git config gitweb.owner '" . $owner{"$repo.git"} . "'");
+        } else {
+            # remove the repository owner setting
+            system("git --git-dir=$repo.git config --unset-all gitweb.owner 2>/dev/null");
+        }
     } else {
         # delete the description file; no messages to user or error checking :)
         unlink $desc_file;
+        # remove the repository owner setting
+        system("git --git-dir=$repo.git config --unset-all gitweb.owner 2>/dev/null");
+    }
+
+    # unless there are other gitweb.* keys set, remove the section to keep the
+    # config file clean
+    my $keys = `git --git-dir=$repo.git config --get-regexp '^gitweb\\.' 2>/dev/null`;
+    if (length($keys) == 0) {
+        system("git --git-dir=$repo.git config --remove-section gitweb 2>/dev/null");
     }
 }
 
 # 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";
+    print $projlist_fh "$proj\n";
 }
 close $projlist_fh;
 
-- 
1.6.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH/gitolite] Tell gitweb about repo owner via git-config
  2010-02-03  8:13 [PATCH/gitolite] Tell gitweb about repo owner via git-config martin f. krafft
@ 2010-02-03 10:28 ` Sitaram Chamarty
  0 siblings, 0 replies; 2+ messages in thread
From: Sitaram Chamarty @ 2010-02-03 10:28 UTC (permalink / raw)
  To: martin f. krafft; +Cc: git

On Wed, Feb 3, 2010 at 1:43 PM, martin f. krafft <madduck@madduck.net> wrote:
> Gitolite uses projects.list to set the owners for gitweb's use.
> Unfortunately, this does not work for gitweb setups that set
> $projectroot to a directory, thus generating the list of
> repositories on the fly.
>
> This patch changes that: gitolite now writes the gitweb.owner
> configuration variable for each repository (and properly cleans up after
> itself if the owner is removed).
>
> The patch causes gitolite not to write the owner to projects.list
> anymore, as this would be redundant.
>
> The owner also needs no longer be escaped, so this patch removes the
> poor man's 's/ /+/g' escaping previously in place.
>
> Note that I am not a Perl coder. Thus there are probably better ways to
> implement this, but at least it works.
>
> Cc: Sitaram Chamarty <sitaramc@gmail.com>
> Signed-off-by: martin f. krafft <madduck@madduck.net>
> ---
>  src/gl-compile-conf |   19 +++++++++++++++++--
>  1 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/src/gl-compile-conf b/src/gl-compile-conf
> index e88819a..7cd5d2e 100755
> --- a/src/gl-compile-conf
> +++ b/src/gl-compile-conf
> @@ -284,7 +284,6 @@ sub parse_conf_file
>             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.git"} = $desc;
> -            $owner =~ s/ /+/g if $owner;    # gitweb/INSTALL wants more, but meh...!
>             $owner{"$repo.git"} = $owner || '';
>         }
>         else
> @@ -414,16 +413,32 @@ for my $repo (sort keys %repos) {
>         $projlist{"$repo.git"} = 1;
>         # add the description file; no messages to user or error checking :)
>         $desc{"$repo.git"} and open(DESC, ">", $desc_file) and print DESC $desc{"$repo.git"} . "\n" and close DESC;
> +        if ($owner{"$repo.git"}) {
> +            # set the repository owner
> +            system("git --git-dir=$repo.git config gitweb.owner '" . $owner{"$repo.git"} . "'");
> +        } else {
> +            # remove the repository owner setting
> +            system("git --git-dir=$repo.git config --unset-all gitweb.owner 2>/dev/null");
> +        }
>     } else {
>         # delete the description file; no messages to user or error checking :)
>         unlink $desc_file;
> +        # remove the repository owner setting
> +        system("git --git-dir=$repo.git config --unset-all gitweb.owner 2>/dev/null");
> +    }
> +
> +    # unless there are other gitweb.* keys set, remove the section to keep the
> +    # config file clean
> +    my $keys = `git --git-dir=$repo.git config --get-regexp '^gitweb\\.' 2>/dev/null`;
> +    if (length($keys) == 0) {
> +        system("git --git-dir=$repo.git config --remove-section gitweb 2>/dev/null");
>     }
>  }
>
>  # 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";
> +    print $projlist_fh "$proj\n";
>  }
>  close $projlist_fh;
>
> --
> 1.6.6
>
>

Thanks; applied to "pu" branch with a slight modification of the git
command that sets the owner (the first one).

-- 
Sitaram

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-02-03 10:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-03  8:13 [PATCH/gitolite] Tell gitweb about repo owner via git-config martin f. krafft
2010-02-03 10:28 ` Sitaram Chamarty

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).