[Rt-commit] [svn] r987 - in RT-Integration-SVN: . html html/SVN lib lib/RT lib/RT/Integration t

jesse at pallas.eruditorum.org jesse at pallas.eruditorum.org
Mon May 31 22:46:53 EDT 2004


Author: jesse
Date: Mon May 31 22:46:53 2004
New Revision: 987

Added:
   RT-Integration-SVN/MANIFEST
   RT-Integration-SVN/META.yml
   RT-Integration-SVN/Makefile.PL
   RT-Integration-SVN/README
   RT-Integration-SVN/html/
   RT-Integration-SVN/html/SVN/
   RT-Integration-SVN/html/SVN/PullUpdate.html   (contents, props changed)
   RT-Integration-SVN/lib/
   RT-Integration-SVN/lib/RT/
   RT-Integration-SVN/lib/RT/Integration/
   RT-Integration-SVN/lib/RT/Integration/SVN.pm
   RT-Integration-SVN/t/
Log:
Initial check. anyone wanna try it?

Added: RT-Integration-SVN/MANIFEST
==============================================================================
--- (empty file)
+++ RT-Integration-SVN/MANIFEST	Mon May 31 22:46:53 2004
@@ -0,0 +1,15 @@
+html/SVN/PullUpdate.html
+inc/Module/Install.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/RTx.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+lib/RT/Integration/SVN.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+README

Added: RT-Integration-SVN/META.yml
==============================================================================
--- (empty file)
+++ RT-Integration-SVN/META.yml	Mon May 31 22:46:53 2004
@@ -0,0 +1,13 @@
+name: RT-Integration-SVN
+version: 0.01_01
+abstract: RT Integration-SVN Extension
+author: Jesse Vincent <jesse at bestpractical.com>
+license: GPLv2
+distribution_type: module
+build_requires:
+  Module::Install::RTx: 0
+no_index:
+  directory:
+    - html
+    - inc
+generated_by: Module::Install version 0.33

Added: RT-Integration-SVN/Makefile.PL
==============================================================================
--- (empty file)
+++ RT-Integration-SVN/Makefile.PL	Mon May 31 22:46:53 2004
@@ -0,0 +1,9 @@
+use inc::Module::Install;
+
+RTx('RT-Integration-SVN');
+license('GPLv2');
+version('0.01_01');
+build_requires('Module::Install::RTx');
+author('Jesse Vincent <jesse at bestpractical.com>');
+
+&WriteAll;

Added: RT-Integration-SVN/README
==============================================================================
--- (empty file)
+++ RT-Integration-SVN/README	Mon May 31 22:46:53 2004
@@ -0,0 +1,67 @@
+This tool allows an RT 3.x instance to integrate with a Subversion revision
+control system.
+
+To configure your subversion server to talk to an RT instance, you'll need 
+to do a bit of setup.
+
+
+In your RT::SiteConfig, set up the following variables:
+
+Set($RT::PathToSvn, '/usr/bin/svn'); # or wherever your svn(1) binary lives
+
+Set($RT::SvnRepository, 'http://svn.example.org/repository/'); 
+# or
+Set($RT::SvnRepository, 'svn://svn.example.org/repository/');  
+
+
+You also need to add a "post-commit" hook to your svn repository
+so that it knows how to talk to RT. Basically, it does a simple
+HTTP "GET" request to tell RT to query the svn server for an update.
+We use this provoked poll method so that RT doesn't need to trust
+arbitrary incoming pings.  RT is careful to only apply each commit
+once.
+
+Create a _privileged_ RT user for the svn integration to use. It doesn't matter
+if that user has no specific rights; they just need to be able to log into RT's
+web interface.
+
+Add the following line (assuming you use curl) to your repository's 
+hooks/post-commit script:
+
+curl -O "http://rt.example.org/SVN/PullUpdate.html?user=guest&pass=guest&rev=$REV" &
+
+
+To tell RT which ticket a commit is associated with, put an RT-Ticket:
+line in your commit message. if there's no RT-Ticket: line, rt will
+ignore the commit message.  If you put "rtname#" before the ticket id, RT
+instances whose rtnames don't match what you've put in will act as if they
+haven't seen a ticket id.  This can be useful if you use svk to move subversion
+commits between repositories and want to track commit history across multiple
+RT instances.
+
+
+A couple simple examples:
+
+=====cut here======
+
+RT-Ticket: fsck.com#123 
+RT-Ticket: elixus.org#1525
+RT-Ticket: openfoundry.org#2113
+RT-Status: resolved
+RT-Update: comment
+
+This is a simple comment.
+
+======cut here=======
+
+    OR 
+
+======cut here=======
+
+RT-Ticket: 123 
+RT-Status: open
+RT-Update: correspond
+
+We've commmited a fix to your problem. Is it fixed in -HEAD?
+
+======cut here=======

Added: RT-Integration-SVN/html/SVN/PullUpdate.html
==============================================================================
--- (empty file)
+++ RT-Integration-SVN/html/SVN/PullUpdate.html	Mon May 31 22:46:53 2004
@@ -0,0 +1,85 @@
+<%ARGS>
+$rev => 1
+</%ARGS>
+<%init>
+
+unless ( $rev =~ /^(\d+)$/ ) {
+    $m->out("Numeric revision needed");
+    $m->abort();
+}
+
+my $REPO = $RT::SvnRepository || "svn://localhost/";
+my $LOOK = $RT::PathToSvn;
+
+my $CHANGE_URI = $REPO . "@" . $rev;
+
+open( SVNLOOK, "$LOOK log $REPO -r $rev|" ) || die $@;
+
+my $dashes = <SVNLOOK>;
+my $data   = <SVNLOOK>;
+my ( $revision, $actor, $foo );
+if ( $data =~ /^r(\d+)\s*\|\s*(.*?)\s*\|/ ) {
+    $revision = $1;
+    $actor    = $2;
+
+}
+die "$rev is not $revision" unless ( $rev == $revision );
+
+my @msg = <SVNLOOK>;
+$dashes = pop(@msg);
+
+close(SVNLOOK);
+
+my $user = RT::CurrentUser->new($actor);
+unless ( $user->id ) {
+    $user->LoadByCols( Gecos => $actor );
+}
+
+unless ( $user->id ) {
+    die "Unknown user";
+}
+
+my $ticket;
+my $update_msg    = '';
+my $update_type   = 'comment';
+my $update_status = '';
+foreach my $line (@msg) {
+    if ( $line =~ /^RT-Ticket: (\w*?)(?:\#?)(\d*)/ ) {
+        next if ($1 && $1 !~ =/^$RT::rtname$/i);
+        $ticket = RT::Ticket->new($user);
+        $ticket->Load($2);
+    }
+    elsif ( $line =~ /^RT-Status:.*(new|open|stalled|resolved|rejected)/i ) {
+        $update_status = lc($1);
+    }
+    elsif ( $line =~ /^RT-Update:\s*(comment|correspond)/i ) {
+        $update_type = lc($1);
+    }
+    else {
+        $update_msg .= $line;
+    }
+
+}
+
+if ( $ticket->id ) {
+    my $refers_to = $ticket->RefersTo;
+    while ( my $refer = $refers_to->Next ) {
+        if ( $refer->TargetURI->URI eq $CHANGE_URI ) {
+            $RT::Logger->error(
+                "Attempt to apply $CHANGE_URI which was already applied");
+            $m->out("Attempt to apply $CHANGE_URI which was already applied");
+            $m->abort();
+            return ();
+        }
+    }
+    $ticket->AddLink( Type => 'RefersTo', Target => $CHANGE_URI );
+
+    $update_msg  = "Subversion update $REPO\@$rev \n" . $update_msg;
+    $update_type = ucfirst($update_type);
+    $ticket->$update_type( Content => $update_msg );
+    if ($update_status) {
+        $ticket->SetStatus($update_status);
+    }
+}
+$m->abort();
+</%init>

Added: RT-Integration-SVN/lib/RT/Integration/SVN.pm
==============================================================================


More information about the Rt-commit mailing list