[Rt-commit] r2710 - in rt/branches/PLATANO-EXPERIMENTAL-CSS: . etc
lib/RT/Interface lib/t/regression
jesse at bestpractical.com
jesse at bestpractical.com
Sat Apr 16 04:17:25 EDT 2005
Author: jesse
Date: Sat Apr 16 04:17:18 2005
New Revision: 2710
Added:
rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/t/regression/19-rtname.t
Modified:
rt/branches/PLATANO-EXPERIMENTAL-CSS/ (props changed)
rt/branches/PLATANO-EXPERIMENTAL-CSS/etc/RT_Config.pm.in
rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Email.pm
Log:
r13099 at hualien: jesse | 2005-04-16 03:11:48 -0400
r12998 at hualien: jesse | 2005-04-16 02:26:28 -0400
r11466 at hualien: jesse | 2005-04-02 04:40:44 -0500
r10696 at hualien: jesse | 2005-03-30 18:19:21 +0800
RT-Ticket: 6544
RT-Status: resolved
RT-Update: correspond
* More graceful handling for historical $rtname tags
-- From seph
Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/etc/RT_Config.pm.in
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/etc/RT_Config.pm.in (original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/etc/RT_Config.pm.in Sat Apr 16 04:17:18 2005
@@ -26,6 +26,14 @@
Set($rtname , "example.com");
+
+# This s regexp controlls what subject tags RT recognizes as its own.
+# be VERY CAREFUL with it. Note that it overrides $rtname.
+# If you're not dealing with historical $rtname values, you'll likely
+# never have to enable this feature
+#
+# Set($EmailSubjectTagRegex, qr/$rtname/ );
+#
# You should set this to your organization's DNS domain. For example,
# fsck.com or asylum.arkham.ma.us. It's used by the linking interface to
# guarantee that ticket URIs are unique and easy to construct.
Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Email.pm
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Email.pm (original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/RT/Interface/Email.pm Sat Apr 16 04:17:18 2005
@@ -437,10 +437,14 @@
# {{{ sub ParseTicketId
+
sub ParseTicketId {
my $Subject = shift;
+ my $id;
+
+ my $test_name = $RT::EmailSubjectTagRegex || qr/\Q$RT::rtname\E/;
- if ( $Subject =~ s/\[\Q$RT::rtname\E\s+\#(\d+)\s*\]//i ) {
+ if ( $Subject =~ s/\[$test_name\s+\#(\d+)\s*\]//i ) {
my $id = $1;
$RT::Logger->debug("Found a ticket ID. It's $id");
return ($id);
Added: rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/t/regression/19-rtname.t
==============================================================================
--- (empty file)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/lib/t/regression/19-rtname.t Sat Apr 16 04:17:18 2005
@@ -0,0 +1,40 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use lib "/opt/rt3.4/lib";
+use lib "/opt/rt3.4/local/lib";
+use Test::More qw/no_plan/;
+
+use_ok("RT");
+
+RT::LoadConfig();
+RT::Init();
+
+use RT::Interface::Email;
+
+# normal use case, regexp set to rtname
+$RT::rtname = "site";
+$RT::EmailSubjectTagRegex = qr/$RT::rtname/ ;
+$RT::rtname = undef;
+is(RT::Interface::Email::ParseTicketId("[site #123] test"), 123);
+is(RT::Interface::Email::ParseTicketId("[othersite #123] test"), undef);
+
+# oops usecase, where the regexp is scragged
+$RT::rtname = "site";
+$RT::EmailSubjectTagRegex = undef;
+is(RT::Interface::Email::ParseTicketId("[site #123] test"), 123);
+is(RT::Interface::Email::ParseTicketId("[othersite #123] test"), undef);
+
+# set to a simple regexp. NOTE: we no longer match "site"
+$RT::rtname = "site";
+$RT::EmailSubjectTagRegex = qr/newsite/;
+is(RT::Interface::Email::ParseTicketId("[site #123] test"), undef);
+is(RT::Interface::Email::ParseTicketId("[newsite #123] test"), 123);
+
+# set to a more complex regexp
+$RT::rtname = "site";
+$RT::EmailSubjectTagRegex = qr/newsite||site/;
+is(RT::Interface::Email::ParseTicketId("[site #123] test"), 123);
+is(RT::Interface::Email::ParseTicketId("[newsite #123] test"), 123);
+is(RT::Interface::Email::ParseTicketId("[othersite #123] test"), undef);
+
More information about the Rt-commit
mailing list