#!/usr/bin/perl ##### # cvsupdate.pl # Version 1.0 # July 26, 2004 # http://www.fastbugtrack.com/ # # Copyright Alcea Technologies Inc., 2004 # All rights reserved. # # # cvsupdate.pl is used to integrate Alcea Fast BugTrack with CVS, # # To install: # 1) Place cvsupdate.pl in a location available to your cvs server process. # (Ex: /usr/local/bin/cvsupdate.pl) # 2) Download and install fbtcmd.pl in a location available to your cvs server # process (Ex: /usr/local/bin/fbtcmd.pl) # 3) ensure that both of these files are executable # 4) Verify that perl is located at /usr/bin/perl, or update line 1 of this # file to match the location of perl. # 5) Set appropriate values for the variables located immediately below... # 6) Tie together with cvs... On a workstation, do a: # a) cvs co CVSROOT # b) cd CVSROOT # c) vi loginfo # d) Add the following line: # ALL (id -un; echo %{sVs}; date; cat) | /usr/local/bin/cvsupdate.pl # e) cvs commit loginfo # 7) When commiting code, include "bug " (where bug# is an existing # bug id within your system). The bug will be marked "Ready to Retest" # (or whatever $STATUS) is set to below... Assigned back to the creator, # and will include the commit description, plus links to cvsweb.cgi... # ##### # # A pointer to the FBT service... Not needed if set in fbtcmd.pl ... # #$SERVICE="http:\/\/DEFAULT.HOSTNAMDEFAULT.HOSTNAMEE.com\/fastbugtrack.wsdl"; # # The FBT command line tool to use when communicating with FBT.. # $FBTCMD="/usr/local/bin/fbtcmd.pl"; # # Status to set issues to... # Leave blank to leave stati unchanged... # $STATUS = "Ready For Retest"; # # Who to auto-assign issues to... # Leave blank to assign to know-one... # Use "[CREATOR]" to assign to the creator of the issue # $ASSIGNEDTO = "[CREATOR]"; # The Keyword to look for from CVS... $LOGMESSAGE= "Log Message"; # DOS world... # $/="\r\n"; $DEBUGLOGFILE="/tmp/cvsupdate.out"; ################ DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW WHAT ################ YOU ARE DOING! :) $logFound = 0; $allData = ""; $log = ""; $firstLine = ""; $secondLine = ""; # # First line contains who did this: # cjustus # Second line contains file(s) updated like this: # phaseOne/mail Network.java,1.1.1.1,1.2 XMLObject.java,1.2,1.3 # Log Message: # Fixing something... bug 123, bug 456, bug 567... # while($line = <>) { if (length($firstLine) == 0) { $firstLine = $line; } elsif (length($secondLine) == 0) { $secondLine = $line; } $allData .= $line; if ($line =~ /$LOGMESSAGE/) { $logFound = 1; } elsif ($logFound == 1) { $log .= $line; } } $workingLog = $log; chomp($firstLine); # # Let's look through logMessage for bug (#), (#), and update the bugs... # # Each bug update will be: # # # For each file: # # phaseOne/mail/Network.java 1.2 1.1.1.1
# phaseOne/mail/XMLObject.java 1.2 #
# while ($workingLog =~ /(bug [\s\#\:\,]*)(\d+)(.*)/is) { ($first,$id,$rest) = ($1,$2,$3); $workingLog = $first . $rest; # Do stuff here! $description = "$log"; $description .= "
"; chop($secondLine); ($directory,@files) = split(/ /,$secondLine); foreach $file (@files) { ($fname, $r1, $r2) = split(/\,/,$file); $description .= "\/${directory}\/${fname}.diff?r1=${r1}&r2=${r2}\">$directory\/${fname} ${r1} ${r2}\n"; } $description .= "<\/FORCE_HTML>"; $command = "${FBTCMD} update --mId=${id} --mEnteredBy=\"${firstLine}\" --stdin=mDescription"; if (length($SERVICE) > 0) { $command .= " --service=\"${SERVICE}\" "; } if (length($STATUS) > 0) { $command .= " --mStatus=\"${STATUS}\" "; } if (length($ASSIGNEDTO) > 0) { $command .= " --mAssignedTo=\"${ASSIGNEDTO}\" "; } if (length($DEBUGLOGFILE) > 0) { open (OUT,">>$DEBUGLOGFILE"); print OUT "Running: $command\n"; print OUT "\nSTDIN: $description\n"; close(OUT); } open(OUT ,"| $command"); print OUT $description; close(OUT); }