Skip to content

Commit

Permalink
- Added a simple SVN link extension that links entries in the form
Browse files Browse the repository at this point in the history
  * repo 123456
  * repo r123456
  * repo #123456
  to the corresponding FreeBSD SVN changeset. Supported repositories are
  base, ports, doc for now.
  • Loading branch information
marcusva committed Sep 22, 2014
1 parent c01647a commit c6a249e
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
12 changes: 12 additions & 0 deletions extensions/SVNLinks/Config.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package Bugzilla::Extension::SVNLinks;
use strict;

use constant NAME => 'SVNLinks';

use constant REQUIRED_MODULES => [
];

use constant OPTIONAL_MODULES => [
];

__PACKAGE__->NAME;
52 changes: 52 additions & 0 deletions extensions/SVNLinks/Extension.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package Bugzilla::Extension::SVNLinks;

use strict;
use warnings;

use base qw(Bugzilla::Extension);

use constant {
SVN_PORTS => "http://svnweb.freebsd.org/changeset/ports/",
SVN_BASE => "http://svnweb.freebsd.org/changeset/base/",
SVN_DOC => "http://svnweb.freebsd.org/changeset/doc/",
};

our $VERSION = '0.1.0';

sub bug_format_comment {
my ($self, $args) = @_;
my $regexes = $args->{regexes};

push(@$regexes, {
match => qr/ports\s*\#?\s*r?(\d+)/i,
replace => \&_link_ports
});
push(@$regexes, {
match => qr/base\s*\#?\s*r?(\d+)/i,
replace => \&_link_base
});
push(@$regexes, {
match => qr/doc\s*\#?\s*r?(\d+)/i,
replace => \&_link_doc
});
}

sub _link_ports {
my $rev = $1 || "";
my $link = "<a href=\"" . SVN_PORTS .
"$rev\" title=\"revision $rev in ports\">ports r$rev</a>";
}

sub _link_base {
my $rev = $1 || "";
my $link = "<a href=\"" . SVN_BASE .
"$rev\" title=\"revision $rev in base\">base r$rev</a>";
}

sub _link_doc {
my $rev = $1 || "";
my $link = "<a href=\"" . SVN_DOC .
"$rev\" title=\"revision $rev in doc\">doc r$rev</a>";
}

__PACKAGE__->NAME;
Empty file added extensions/SVNLinks/disabled
Empty file.

0 comments on commit c6a249e

Please sign in to comment.