# This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # extensions # extensions/AutoAssign # extensions/AutoAssign/lib # extensions/AutoAssign/lib/Util.pm # extensions/AutoAssign/web # extensions/AutoAssign/web/README # extensions/AutoAssign/template # extensions/AutoAssign/template/en # extensions/AutoAssign/template/en/default # extensions/AutoAssign/template/en/default/hook # extensions/AutoAssign/template/en/default/hook/README # extensions/AutoAssign/template/en/default/autoassign # extensions/AutoAssign/template/en/default/autoassign/README # extensions/AutoAssign/Config.pm # extensions/AutoAssign/Extension.pm # echo c - extensions mkdir -p extensions > /dev/null 2>&1 echo c - extensions/AutoAssign mkdir -p extensions/AutoAssign > /dev/null 2>&1 echo c - extensions/AutoAssign/lib mkdir -p extensions/AutoAssign/lib > /dev/null 2>&1 echo x - extensions/AutoAssign/lib/Util.pm sed 's/^X//' >extensions/AutoAssign/lib/Util.pm << '696c8449ea01107251a777cad360621b' Xpackage Bugzilla::Extension::AutoAssign::Util; Xuse strict; Xuse base qw(Exporter); Xour @EXPORT = qw( X X); X X# This file can be loaded by your extension via X# "use Bugzilla::Extension::AutoAssign::Util". You can put functions X# used by your extension in here. (Make sure you also list them in X# @EXPORT.) X X1; 696c8449ea01107251a777cad360621b echo c - extensions/AutoAssign/web mkdir -p extensions/AutoAssign/web > /dev/null 2>&1 echo x - extensions/AutoAssign/web/README sed 's/^X//' >extensions/AutoAssign/web/README << '5225bca7582f417f6f84077eff0210d4' XWeb-accessible files, like JavaScript, CSS, and images go in this Xdirectory. You can reference them directly in your HTML. For example, Xif you have a file called "style.css" and your extension is called X"Foo", you would put it in "extensions/Foo/web/style.css", and then Xyou could link to it in HTML like: X X 5225bca7582f417f6f84077eff0210d4 echo c - extensions/AutoAssign/template mkdir -p extensions/AutoAssign/template > /dev/null 2>&1 echo c - extensions/AutoAssign/template/en mkdir -p extensions/AutoAssign/template/en > /dev/null 2>&1 echo c - extensions/AutoAssign/template/en/default mkdir -p extensions/AutoAssign/template/en/default > /dev/null 2>&1 echo c - extensions/AutoAssign/template/en/default/hook mkdir -p extensions/AutoAssign/template/en/default/hook > /dev/null 2>&1 echo x - extensions/AutoAssign/template/en/default/hook/README sed 's/^X//' >extensions/AutoAssign/template/en/default/hook/README << '5cfe35d75fd0a333c8eff74dada11603' XTemplate hooks go in this directory. Template hooks are called in normal XBugzilla templates like [% Hook.process('some-hook') %]. XMore information about them can be found in the documentation of XBugzilla::Extension. (Do "perldoc Bugzilla::Extension" from the main XBugzilla directory to see that documentation.) 5cfe35d75fd0a333c8eff74dada11603 echo c - extensions/AutoAssign/template/en/default/autoassign mkdir -p extensions/AutoAssign/template/en/default/autoassign > /dev/null 2>&1 echo x - extensions/AutoAssign/template/en/default/autoassign/README sed 's/^X//' >extensions/AutoAssign/template/en/default/autoassign/README << '7aa1a750e39357b7d113404778047264' XNormal templates go in this directory. You can load them in your Xcode like this: X Xuse Bugzilla::Error; Xmy $template = Bugzilla->template; X$template->process('autoassign/some-template.html.tmpl') X or ThrowTemplateError($template->error()); X XThat would be how to load a file called some-template.html.tmpl that Xwas in this directory. X XNote that you have to be careful that the full path of your template Xnever conflicts with a template that exists in Bugzilla or in Xanother extension, or your template might override that template. That's why Xwe created this directory called 'autoassign' for you, so you Xcan put your templates in here to help avoid conflicts. 7aa1a750e39357b7d113404778047264 echo x - extensions/AutoAssign/Config.pm sed 's/^X//' >extensions/AutoAssign/Config.pm << '5d47cfd1afc2c3aefc62320a3a4a600e' Xpackage Bugzilla::Extension::AutoAssign; Xuse strict; X Xuse constant NAME => 'AutoAssign'; X Xuse constant REQUIRED_MODULES => [ X]; X Xuse constant OPTIONAL_MODULES => [ X]; X X__PACKAGE__->NAME; 5d47cfd1afc2c3aefc62320a3a4a600e echo x - extensions/AutoAssign/Extension.pm sed 's/^X//' >extensions/AutoAssign/Extension.pm << 'bdb669f3bca0c573299ddc15af22294e' Xpackage Bugzilla::Extension::AutoAssign; Xuse strict; Xuse base qw(Bugzilla::Extension); X Xuse Bugzilla::Comment; Xuse Bugzilla::User; X Xour $VERSION = '0.1.0'; X Xsub bug_end_of_create { X my ($self, $args) = @_; X my $bug = $args->{'bug'}; X my $timestamp = $args->{'timestamp'}; X X # Is it a mapped assignee? X # TODO: X # if ($bug->creator in mapping_list) { X # $bug->assigned_to = mapping_list["user"] X # return; X # } X X # Is it a port patch in summary matching ([A-Za-z0-9_-]/[A-Za-z0-9_-])? X my @res = ($bug->short_desc =~ /([\w-]+\/[\w-]+)/g); X if (@res) { X if (scalar(@res) == 1) { X # Found exactly one entry: cat/port X warn("Found port '$res[0]' in summary"); X # X # TODO: ${PORTSDIR} should not be hardcoded X # X my $fname = "/usr/ports/$res[0]/Makefile"; X if (open(my $file, "<", $fname)) { X my @maintainer = grep(s/^MAINTAINER=[ \t]+(.*)\s$/$1/, <$file>); X if (@maintainer) { X my $userid = login_to_id($maintainer[0]); X if ($userid) { X my $user = new Bugzilla::User($userid); X if ($user) { X $bug->set_assigned_to($user); X $bug->add_comment("auto-assigned to maintainer"); X } else { X warn("Could not find user for '$maintainer[0]'"); X } X } else { X warn("Could not find user id for '$maintainer[0]'"); X } X } else { X warn("Could not find MAINTAINER in $fname"); X } X close($file); X } else { X warn("Could not open $fname"); X } X return; X } elsif (scalar(@res) > 1) { X # Found more than one entry; we're confused now - what should be X # done? Best is not to do anything... X warn("Found mutiple ports in summary; I won't do anything"); X return; X } X } else { X # Could not determine any cat/port in the summary X warn("Could not extract category/port from summary"); X } X X # Is it a port patch in the comment? X # if ($bug->description matches category/port) { X # maintainer = grep -eR "MAINTAINER=" category/port X # $bug->assigned_to = maintainer X # return X # } X X # Is there something in the attachments? X # if ($bug->attachments contains category/port) X # ... X return; X} X X__PACKAGE__->NAME; bdb669f3bca0c573299ddc15af22294e exit