{"thread":{"id":"22502","subject":"[PATCH/gitolite] Tell gitweb about repo owner via git-config","startedAt":"2010-02-03T08:13:47Z","lastAt":"2010-02-03T10:28:42Z","messageCount":2,"participants":["martin f. krafft","Sitaram Chamarty"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"133449","messageId":"1265184827-11364-1-git-send-email-madduck@madduck.net","threadId":"22502","inReplyTo":null,"subject":"[PATCH/gitolite] Tell gitweb about repo owner via git-config","fromName":"martin f. krafft","fromEmail":"madduck@madduck.net","sentAt":"2010-02-03T08:13:47Z","receivedAt":"2010-02-03T08:13:47Z","isPatch":true,"sender":{"key":"madduck@madduck.net","avatar":null},"body":"Gitolite uses projects.list to set the owners for gitweb's use.\nUnfortunately, this does not work for gitweb setups that set\n$projectroot to a directory, thus generating the list of\nrepositories on the fly.\n\nThis patch changes that: gitolite now writes the gitweb.owner\nconfiguration variable for each repository (and properly cleans up after\nitself if the owner is removed).\n\nThe patch causes gitolite not to write the owner to projects.list\nanymore, as this would be redundant.\n\nThe owner also needs no longer be escaped, so this patch removes the\npoor man's 's/ /+/g' escaping previously in place.\n\nNote that I am not a Perl coder. Thus there are probably better ways to\nimplement this, but at least it works.\n\nCc: Sitaram Chamarty <sitaramc@gmail.com>\nSigned-off-by: martin f. krafft <madduck@madduck.net>\n---\n src/gl-compile-conf |   19 +++++++++++++++++--\n 1 files changed, 17 insertions(+), 2 deletions(-)\n\ndiff --git a/src/gl-compile-conf b/src/gl-compile-conf\nindex e88819a..7cd5d2e 100755\n--- a/src/gl-compile-conf\n+++ b/src/gl-compile-conf\n@@ -284,7 +284,6 @@ sub parse_conf_file\n             die \"$WARN $fragment attempting to set description for $repo\\n\" if\n                 $fragment ne 'master' and $fragment ne $repo and ($groups{\"\\@$fragment\"}{$repo} || '') ne 'master';\n             $desc{\"$repo.git\"} = $desc;\n-            $owner =~ s/ /+/g if $owner;    # gitweb/INSTALL wants more, but meh...!\n             $owner{\"$repo.git\"} = $owner || '';\n         }\n         else\n@@ -414,16 +413,32 @@ for my $repo (sort keys %repos) {\n         $projlist{\"$repo.git\"} = 1;\n         # add the description file; no messages to user or error checking :)\n         $desc{\"$repo.git\"} and open(DESC, \">\", $desc_file) and print DESC $desc{\"$repo.git\"} . \"\\n\" and close DESC;\n+        if ($owner{\"$repo.git\"}) {\n+            # set the repository owner\n+            system(\"git --git-dir=$repo.git config gitweb.owner '\" . $owner{\"$repo.git\"} . \"'\");\n+        } else {\n+            # remove the repository owner setting\n+            system(\"git --git-dir=$repo.git config --unset-all gitweb.owner 2>/dev/null\");\n+        }\n     } else {\n         # delete the description file; no messages to user or error checking :)\n         unlink $desc_file;\n+        # remove the repository owner setting\n+        system(\"git --git-dir=$repo.git config --unset-all gitweb.owner 2>/dev/null\");\n+    }\n+\n+    # unless there are other gitweb.* keys set, remove the section to keep the\n+    # config file clean\n+    my $keys = `git --git-dir=$repo.git config --get-regexp '^gitweb\\\\.' 2>/dev/null`;\n+    if (length($keys) == 0) {\n+        system(\"git --git-dir=$repo.git config --remove-section gitweb 2>/dev/null\");\n     }\n }\n \n # update the project list\n my $projlist_fh = wrap_open( \">\", $PROJECTS_LIST);\n for my $proj (sort keys %projlist) {\n-    print $projlist_fh \"$proj\" . ( $owner{$proj} ? \" $owner{$proj}\" : \"\" ) . \"\\n\";\n+    print $projlist_fh \"$proj\\n\";\n }\n close $projlist_fh;\n \n-- \n1.6.6\n"},{"id":"133462","messageId":"2e24e5b91002030228h12c3fa78pe1cece1de09876de@mail.gmail.com","threadId":"22502","inReplyTo":"1265184827-11364-1-git-send-email-madduck@madduck.net","subject":"Re: [PATCH/gitolite] Tell gitweb about repo owner via git-config","fromName":"Sitaram Chamarty","fromEmail":"sitaramc@gmail.com","sentAt":"2010-02-03T10:28:42Z","receivedAt":"2010-02-03T10:28:42Z","isPatch":true,"sender":{"key":"sitaramc@gmail.com","avatar":"https://avatars.githubusercontent.com/u/43316?v=4"},"body":"On Wed, Feb 3, 2010 at 1:43 PM, martin f. krafft <madduck@madduck.net> wrote:\n> Gitolite uses projects.list to set the owners for gitweb's use.\n> Unfortunately, this does not work for gitweb setups that set\n> $projectroot to a directory, thus generating the list of\n> repositories on the fly.\n>\n> This patch changes that: gitolite now writes the gitweb.owner\n> configuration variable for each repository (and properly cleans up after\n> itself if the owner is removed).\n>\n> The patch causes gitolite not to write the owner to projects.list\n> anymore, as this would be redundant.\n>\n> The owner also needs no longer be escaped, so this patch removes the\n> poor man's 's/ /+/g' escaping previously in place.\n>\n> Note that I am not a Perl coder. Thus there are probably better ways to\n> implement this, but at least it works.\n>\n> Cc: Sitaram Chamarty <sitaramc@gmail.com>\n> Signed-off-by: martin f. krafft <madduck@madduck.net>\n> ---\n>  src/gl-compile-conf |   19 +++++++++++++++++--\n>  1 files changed, 17 insertions(+), 2 deletions(-)\n>\n> diff --git a/src/gl-compile-conf b/src/gl-compile-conf\n> index e88819a..7cd5d2e 100755\n> --- a/src/gl-compile-conf\n> +++ b/src/gl-compile-conf\n> @@ -284,7 +284,6 @@ sub parse_conf_file\n>             die \"$WARN $fragment attempting to set description for $repo\\n\" if\n>                 $fragment ne 'master' and $fragment ne $repo and ($groups{\"\\@$fragment\"}{$repo} || '') ne 'master';\n>             $desc{\"$repo.git\"} = $desc;\n> -            $owner =~ s/ /+/g if $owner;    # gitweb/INSTALL wants more, but meh...!\n>             $owner{\"$repo.git\"} = $owner || '';\n>         }\n>         else\n> @@ -414,16 +413,32 @@ for my $repo (sort keys %repos) {\n>         $projlist{\"$repo.git\"} = 1;\n>         # add the description file; no messages to user or error checking :)\n>         $desc{\"$repo.git\"} and open(DESC, \">\", $desc_file) and print DESC $desc{\"$repo.git\"} . \"\\n\" and close DESC;\n> +        if ($owner{\"$repo.git\"}) {\n> +            # set the repository owner\n> +            system(\"git --git-dir=$repo.git config gitweb.owner '\" . $owner{\"$repo.git\"} . \"'\");\n> +        } else {\n> +            # remove the repository owner setting\n> +            system(\"git --git-dir=$repo.git config --unset-all gitweb.owner 2>/dev/null\");\n> +        }\n>     } else {\n>         # delete the description file; no messages to user or error checking :)\n>         unlink $desc_file;\n> +        # remove the repository owner setting\n> +        system(\"git --git-dir=$repo.git config --unset-all gitweb.owner 2>/dev/null\");\n> +    }\n> +\n> +    # unless there are other gitweb.* keys set, remove the section to keep the\n> +    # config file clean\n> +    my $keys = `git --git-dir=$repo.git config --get-regexp '^gitweb\\\\.' 2>/dev/null`;\n> +    if (length($keys) == 0) {\n> +        system(\"git --git-dir=$repo.git config --remove-section gitweb 2>/dev/null\");\n>     }\n>  }\n>\n>  # update the project list\n>  my $projlist_fh = wrap_open( \">\", $PROJECTS_LIST);\n>  for my $proj (sort keys %projlist) {\n> -    print $projlist_fh \"$proj\" . ( $owner{$proj} ? \" $owner{$proj}\" : \"\" ) . \"\\n\";\n> +    print $projlist_fh \"$proj\\n\";\n>  }\n>  close $projlist_fh;\n>\n> --\n> 1.6.6\n>\n>\n\nThanks; applied to \"pu\" branch with a slight modification of the git\ncommand that sets the owner (the first one).\n\n-- \nSitaram\n"}]}