update
[ikiwiki] / doc / patchqueue / webcommit-from.mdwn
1 Looks good, [[patchqueue/done]] -- [[Joey]]
2
3 From [[Faidon]]:
4         
5 Match 'web commit from' in SVN and git, these are web
6 commits too. Show the IP instead of the user 'www-data' (which is kind
7 of security fix too, since the user Apache is running as was visible).
8
9 Note that the git backend patch is untested.
10 Recai, could you test it? (if Joey finds the change acceptable that is).
11         
12         Index: IkiWiki/Rcs/svn.pm
13         ===================================================================
14         --- IkiWiki/Rcs/svn.pm  (revision 904)
15         +++ IkiWiki/Rcs/svn.pm  (working copy)
16         @@ -7,7 +7,7 @@
17          
18          package IkiWiki;
19                         
20         -my $svn_webcommit=qr/^web commit by (\w+):?(.*)/;
21         +my $svn_webcommit=qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/;
22          
23          sub svn_info ($$) { #{{{
24                 my $field=shift;
25         @@ -136,8 +136,8 @@
26                         my $committype="web";
27                         if (defined $message[0] &&
28                             $message[0]->{line}=~/$svn_webcommit/) {
29         -                       $user="$1";
30         -                       $message[0]->{line}=$2;
31         +                       $user=defined $2 ? "$2" : "$3";
32         +                       $message[0]->{line}=$4;
33                         }
34                         else {
35                                 $committype="svn";
36         @@ -178,8 +178,8 @@
37                 chomp $user;
38                 my $message=`svnlook log $config{svnrepo} -r $rev`;
39                 if ($message=~/$svn_webcommit/) {
40         -               $user="$1";
41         -               $message=$2;
42         +               $user=defined $2 ? "$2" : "$3";
43         +               $message=$4;
44                 }
45          
46                 my @changed_pages;
47         Index: IkiWiki/Rcs/git.pm
48         ===================================================================
49         --- IkiWiki/Rcs/git.pm  (revision 904)
50         +++ IkiWiki/Rcs/git.pm  (working copy)
51         @@ -12,7 +12,7 @@
52          my $master_branch    = 'master';            # working branch
53          my $sha1_pattern     = qr/[0-9a-fA-F]{40}/; # pattern to validate Git sha1sums
54          my $dummy_commit_msg = 'dummy commit';      # message to skip in recent changes
55         -my $web_commit_msg   = qr/^web commit by (\w+):?(.*)/; # pattern for web commits
56         +my $web_commit_msg   = qr/^web commit (by (\w+)|from (\d+\.\d+\.\d+\.\d+)):?(.*)/;
57          
58          sub _safe_git (&@) { #{{{
59                 # Start a child process safely without resorting /bin/sh.
60         @@ -377,8 +377,8 @@
61          
62                         if (defined $message[0] &&
63                             $message[0]->{line} =~ m/$web_commit_msg/) {
64         -                       $user = "$1";
65         -                       $message[0]->{line} = $2;
66         +                       $user=defined $2 ? "$2" : "$3";
67         +                       $message[0]->{line}=$4;
68                         } else {
69                                 $type ="git";
70                                 $user = $ci->{'author_username'};
71         @@ -426,8 +426,8 @@
72          
73                 my ($user, $message);
74                 if (@{ $ci->{'comment'} }[0] =~ m/$web_commit_msg/) {
75         -               $user    = "$1";
76         -               $message = $2;
77         +               $user    = defined $2 ? "$2" : "$3";
78         +               $message = $4;
79                 } else {
80                         $user    = $ci->{'author_username'};
81                         $message = join "\n", @{ $ci->{'comment'} };