{"thread":{"id":"9284","subject":"[PATCH] gitweb: localhost placeholder parser for cloneurl file","startedAt":"2007-07-29T06:54:33Z","lastAt":"2007-07-29T23:57:01Z","messageCount":2,"participants":["Leandro Dorileo","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"48956","messageId":"d68f80d90707282354l1593f2ctc0cf7a05eeb3b8e0@mail.gmail.com","threadId":"9284","inReplyTo":null,"subject":"[PATCH] gitweb: localhost placeholder parser for cloneurl file","fromName":"Leandro Dorileo","fromEmail":"ldorileo@gmail.com","sentAt":"2007-07-29T06:54:33Z","receivedAt":"2007-07-29T06:54:33Z","isPatch":true,"sender":{"key":"ldorileo@gmail.com","avatar":null},"body":"Hi...\n\nI just started to use gitweb and saw that there isn`t in the git-tree\nof gitweb the feature of that link to the git url (wich we can see in\ngit.kernel.org:D - I didn`t understand it, was that changed/done only\nfor kernel.org?).\nI also have a specific need. I work with my laptop and there I keep\nsome git repositories, these repositories are shared/published with\nsome coworkers but as it`s a notebook the network environment normally\nchanges depending where I`m, so I implemented a placeholder for\ncloneurl file. Gitweb will change #localhost# by  server_name.\n\nIf your git repositories aren`t in your local machine or if your\ngitweb is hosted in a specific server what you have to do (in fact\nwhat you don`t have to do :D) is just not use it.\n\n>From 32da24e1e18a1c5f32bfa0afdbcb6d0f2b0432f3 Mon Sep 17 00:00:00 2001\nFrom: Leandro Dorileo <dorileo@ossystems.com.br>\nDate: Sat, 28 Jul 2007 15:34:20 -0400\nSubject: [PATCH] gitweb: localhost placeholder parser for cloneurl file\n\nImplementation of a localhost placeholder parsing in git_get_project_url_list.\nIt`s useful in cases of gitweb being hosted in a work-station (like a notebook)\nused in a local team development environment and, implementation of a git-url\nlink in the git project list body like in git.kernel.org.\n---\n gitweb/gitweb.perl |   21 ++++++++++++++++++---\n 1 files changed, 18 insertions(+), 3 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex b381692..281d823 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -1471,7 +1471,16 @@ sub git_get_project_url_list {\n \tmy @git_project_url_list = map { chomp; $_ } <$fd>;\n \tclose $fd;\n\n-\treturn wantarray ? @git_project_url_list : \\@git_project_url_list;\n+        if(wantarray){\n+            for(my $i = 0; $i < @git_project_url_list; $i++){\n+                if(index(@git_project_url_list[$i], \"#localhost#\") != -1){\n+                    @git_project_url_list[$i] =~\ns/#localhost#/server_name()/eg;\n+                }\n+            }\n+            return @git_project_url_list;\n+        }else{\n+            return \\@git_project_url_list;\n+        }\n }\n\n sub git_get_projects_list {\n@@ -3384,8 +3393,14 @@ sub git_project_list_body {\n \t\t      $cgi->a({-href => href(project=>$pr->{'path'},\naction=>\"shortlog\")}, \"shortlog\") . \" | \" .\n \t\t      $cgi->a({-href => href(project=>$pr->{'path'},\naction=>\"log\")}, \"log\") . \" | \" .\n \t\t      $cgi->a({-href => href(project=>$pr->{'path'},\naction=>\"tree\")}, \"tree\") .\n-\t\t      ($pr->{'forks'} ? \" | \" . $cgi->a({-href =>\nhref(project=>$pr->{'path'}, action=>\"forks\")}, \"forks\") : '') .\n-\t\t      \"</td>\\n\" .\n+\t\t      ($pr->{'forks'} ? \" | \" . $cgi->a({-href =>\nhref(project=>$pr->{'path'}, action=>\"forks\")}, \"forks\") : '');\n+\n+                      my @url_list = git_get_project_url_list($pr->{'path'});\n+                      if(@url_list != 0){\n+                        print \" | \" . $cgi->a({-href => @url_list[0]}, \"git\");\n+                      }\n+\n+\t\t      print \"</td>\\n\" .\n \t\t      \"</tr>\\n\";\n \t}\n \tif (defined $extra) {\n-- \n1.5.2.4\n\n-- \nDorileo\n"},{"id":"49035","messageId":"f8j9gb$voj$1@sea.gmane.org","threadId":"9284","inReplyTo":"d68f80d90707282354l1593f2ctc0cf7a05eeb3b8e0@mail.gmail.com","subject":"Re: [PATCH] gitweb: localhost placeholder parser for cloneurl file","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2007-07-29T23:57:01Z","receivedAt":"2007-07-29T23:57:01Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"[Cc: Leandro Dorileo <ldorileo@gmail.com>, git@vger.kernel.org]\n\nLeandro Dorileo wrote:\n\n> From 32da24e1e18a1c5f32bfa0afdbcb6d0f2b0432f3 Mon Sep 17 00:00:00 2001\n> From: Leandro Dorileo <dorileo@ossystems.com.br>\n> Date: Sat, 28 Jul 2007 15:34:20 -0400\n> Subject: [PATCH] gitweb: localhost placeholder parser for cloneurl file\n> \n> Implementation of a localhost placeholder parsing in git_get_project_url_list.\n> It`s useful in cases of gitweb being hosted in a work-station (like a notebook)\n> used in a local team development environment and, implementation of a git-url\n> link in the git project list body like in git.kernel.org.\n\nFirst, the commit message _has_ to be self explanatory, and be easily\nunderstood _without_ email message which introduced it.\n\nSo you should clean-up the explanation about _why_ one would want to\nreplace #localhost#, or ++LOCALHOST++ in the cloneurls by the server\nname (the same configuration, different machines; although I do not\nunderstand why it is so hard to change configutation depending on\nmachine).\n\nSecond, please clean up the code. Comments below.\n\nThird, sign-off your patches: see Documentation/SubmittingPatches\n\n> ---\n>  gitweb/gitweb.perl |   21 ++++++++++++++++++---\n>  1 files changed, 18 insertions(+), 3 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index b381692..281d823 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -1471,7 +1471,16 @@ sub git_get_project_url_list {\n>       my @git_project_url_list = map { chomp; $_ } <$fd>;\n>       close $fd;\n> \n> -     return wantarray ? @git_project_url_list : \\@git_project_url_list;\n> +        if(wantarray){\n\nStyle: \"if (wantarray) {\".\n\nBut I think you would want to do the substitution regardless of\nwhether git_get_project_url_list() subroutine is called in scalar\nor list context. (By the way I think it might be a mistake to use\nthis trick: return array in the list context, return array reference\nin the scalar context).\n\nSo you would put the code proposed below before\n\n        return wantarray ? @git_project_url_list : \\@git_project_url_list;\n\n> +            for(my $i = 0; $i < @git_project_url_list; $i++){\n> +                if(index(@git_project_url_list[$i], \"#localhost#\") != -1){\n> +                    @git_project_url_list[$i] =~\n> s/#localhost#/server_name()/eg;\n> +                }\n> +            }\n\nWhy not simply:\n\n        @git_project_url_list = map { s/#localhost#/server_name()/eg; } \n                @git_project_url_list;\n\nAnd didn't you meant $cgi->server_name() or just $ENV{'SERVER_NAME'}?\n\n> +            return @git_project_url_list;\n> +        }else{\n> +            return \\@git_project_url_list;\n> +        }\n\nJust end with what it was before:\n\n        return wantarray ? @git_project_url_list : \\@git_project_url_list;\n\n>  }\n \n>  sub git_get_projects_list {\n> @@ -3384,8 +3393,14 @@ sub git_project_list_body {\n>                     $cgi->a({-href => href(project=>$pr->{'path'},\n> action=>\"shortlog\")}, \"shortlog\") . \" | \" .\n>                     $cgi->a({-href => href(project=>$pr->{'path'},\n> action=>\"log\")}, \"log\") . \" | \" .\n>                     $cgi->a({-href => href(project=>$pr->{'path'},\n> action=>\"tree\")}, \"tree\") .\n> -                   ($pr->{'forks'} ? \" | \" . $cgi->a({-href =>\n> href(project=>$pr->{'path'}, action=>\"forks\")}, \"forks\") : '') .\n> -                   \"</td>\\n\" .\n> +                   ($pr->{'forks'} ? \" | \" . $cgi->a({-href =>\n> href(project=>$pr->{'path'}, action=>\"forks\")}, \"forks\") : '');\n> +\n> +                      my @url_list = git_get_project_url_list($pr->{'path'});\n> +                      if(@url_list != 0){\n> +                        print \" | \" . $cgi->a({-href => @url_list[0]}, \"git\");\n> +                      }\n\nStyle: \"if (@url_list) {\" is enough.\nStyle: use tabs for indent, now spaces.\n\nBut this is totally independent thing, and it should be put in\nseparate patch. And it doesn't make much sense as first URL in\nthe list might not be using scheme recognized by web browser:\n - it can be git:// URL.\n - it can be scp style ssh:// URL: <user>@<host>:<path>\n - it can be local path, without file:// prefix\n\n> +\n> +                   print \"</td>\\n\" .\n>                     \"</tr>\\n\";\n>       }\n>       if (defined $extra) {\n\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}