Hi all,
We're considering to switch from CVS to Subversion. We had our own
home-brewn glue between CVS, Bugzilla and CVSweb to do
autolinkification, which obviously won't work with Subversion. Since
Scmbug provides the same kind of functionality for a number of SCM
systems we're seriously considering to use it.
I found a patch by Aleksey
(http://bugzilla.mkgnu.net/show_bug.cgi?id=266) to do
autolinkification more or less the way we did it, but I missed some
hyperlinks. So I started to hack a bit of Perl myself.
It's my first piece of real Perl code, so it will probably have some
rough edges. Please feel free to modify/improve/... it. I think the code
is self-explanatory. I wanted to send it as an attachment for the
aforementioned bug, but I did not have a legitimate login name, so I
attached it to this mail.
Note: for Bugzilla 2.22.x the trick with defparams.pl does not work and
I haven't been able to figure out how to do it the proper way using
template hooks. Anyone?
Regards,
Marcel Loose
diff -ru bugzilla-2.18.6/defparams.pl bugzilla-2.18.6-patched/defparams.pl
--- bugzilla-2.18.6/defparams.pl 2006-02-20 23:40:56.000000000 +0000
+++ bugzilla-2.18.6-patched/defparams.pl 2007-07-02 12:55:16.000000000
+0000
@@ -1192,6 +1192,15 @@
type => 'b',
default => 0,
},
+
+ {
+ name => 'viewvcurl',
+ desc => 'URL to a ViewVC installation. By setting this ' .
+ 'auto-linkification of Scmbug commit logs is enabled',
+ type => 't',
+ default => '',
+ checker => \&check_urlbase
+ },
);
1;
diff -ru bugzilla-2.18.6/globals.pl bugzilla-2.18.6-patched/globals.pl
--- bugzilla-2.18.6/globals.pl 2006-10-14 21:11:08.000000000 +0000
+++ bugzilla-2.18.6-patched/globals.pl 2007-07-02 12:55:12.000000000 +0000
@@ -967,6 +967,12 @@
~GetBugLink($1, $1)
~egmx;
+ # Check for a Scmbug commit log message and create links for ViewVC.
+ $text =~ s~(?<=Affected\ files:\n---------------\n)
+ (.*)
+ ~GetScmbugCommitLinks($1)
+ ~egsx;
+
# Now remove the encoding hacks
$text =~ s/\0\0(\d+)\0\0/$things[$1]/eg;
$text =~ s/$chr1\0/\0/g;
@@ -974,6 +980,97 @@
return $text;
}
+sub GetScmbugCommitLinks {
+ # Refs: https://bugzilla.mozilla.org/show_bug.cgi?id=314097
+ # http://bugzilla.mkgnu.net/show_bug.cgi?id=266
+ #
+ # Commander: match SCMBUG comments
+ # 388 --> 391 trunk/Common/Src/HashCell.cpp
+ # 388 --> 391 PDX:trunk/Common/Src/HashCell.cpp
+ # NONE --> 391 trunk/Common/Src/HashCell.cpp
+ # NONE --> 391 PDX:trunk/Common/Src/HashCell.cpp
+ # 388 --> 391 trunk/
+ # 388 --> 391 /
+ # 388 --> 391 PDX:trunk/
+ # 388 --> 391 PDX:/
+ # 388 --> NONE trunk/Test.txt
+ # 388 --> NONE PDX:trunk/Test.txt
+ # 388 --> NONE trunk/Test/
+ # 388 --> NONE /
+ # 388 --> NONE PDX:trunk/Test/
+ # 388 --> NONE PDX:trunk/
+
+ my $vcurl = Param("viewvcurl");
+
+ my $html = "\n<table cellspacing=0 cellpadding=\"0\">";
+ my $style = 'style="padding-left: 2em"';
+
+ my @lines = split("\n", $_[0]);
+
+ my $l;
+ foreach $l (@lines) {
+ my @w = $l =~
+ m~(?<=^) # The beginning of the line
+ (\d+|NONE) # 0 The previous revision
+ (\s*-->\s*) # 1 The arrow and spaces before/after
+ (\d+|NONE) # 2 The current revision
+ (\s*) # 3 The space immediately after
+ ( # 4 The entire file/directory name
+ ( # 5 The project prefix [optional]
+ ([\w\.]+) # 6 Just the project name itself
+ \:
+ )?
+ ( # 7 The file/directory name
+ ( # 8 The file must NOT end with a slash
+ [\w\.][\w\/\.\ ]*\w|\w
+ )
+ |
+ ( # 9 The dir MUST end with a slash
+ ( #10 The dir name WITHOUT the trailing slash
+ [\w\/\.\ ]*
+ )
+ \/
+ )
+ )
+ )
+ (?=$) # The end of the line
+ ~gx;
+
+ # If @w is empty, then line did not match: continue with next line.
+ next if [EMAIL PROTECTED];
+
+ my $filepath = "$vcurl" . (defined($w[6]) ? "$w[6]/" : "") . "$w[7]";
+ my $filelink = "<a href=\"$filepath?view=log&pathrev="
+ . ($w[0] ne "NONE" ? $w[0] : $w[2])
+ . "\">$w[7]</a>";
+ my $rev1link = ($w[0] eq "NONE")
+ ? $w[0]
+ : "<a href=\"$filepath?pathrev=$w[0]"
+ . (defined($w[9]) ? "" : "&view=markup")
+ . "\">$w[0]</a>";
+ my $rev2link = ($w[2] eq "NONE")
+ ? $w[2]
+ : "<a href=\"$filepath?pathrev=$w[2]"
+ . (defined($w[9]) ? "" : "&view=markup")
+ . "\">$w[2]</a>";
+ my $difflink = (($w[0] eq "NONE") || ($w[2] eq "NONE"))
+ ? $w[1]
+ : "<a href=\"$filepath?pathrev=$w[0]"
+ . "&r1=$w[0]&r2=$w[2]\">$w[1]</a>";
+ $html .= "\n<tr>"
+ . "<td>$rev1link</td>"
+ . " <td $style>$difflink</td>"
+ . " <td $style>$rev2link</td>"
+ . " <td $style></td>"
+ . " <td $style>$filelink</td>"
+ . "</tr>";
+ }
+
+ $html .= "\n</table>";
+
+ return $html;
+}
+
# GetAttachmentLink creates a link to an attachment,
# including its title.
_______________________________________________
scmbug-users mailing list
[email protected]
http://lists.mkgnu.net/cgi-bin/mailman/listinfo/scmbug-users