Subversion integration

Problems installing, configuring or using any of the built-in modules?

Subversion integration

Postby Xandros123 » Sat Jun 13, 2009 9:16 pm

After some investigation and after installed all software components to integrate subversion with BugGenie2 I had more 2 problem to solve:

- write a post-commit hooks running on windows system (.bat)
- hack some php file of post-commit.php that use Linux path and that doesn't work on Windows OS

I send you the 2 file neeeded to complete the windows SVN-BG2 integration on Windows system.
I ask you to check it and add it at standard file for windows SVN integration for other user benefits.

If you enable me, I can attach the 2 file.
Thaks.
Xandros123
 
Posts: 4
Joined: Sat Jun 13, 2009 9:07 pm

Re: Subversion integration

Postby zegenie » Sat Jun 13, 2009 11:46 pm

Great stuff! Feel free to email them to me, and I'll add them as soon as possible. Unfortunately I don't have the possibility to enable uploads on the forums at the moment :(
User avatar
zegenie
Site Admin
 
Posts: 215
Joined: Wed May 13, 2009 7:36 pm

Re: Subversion integration

Postby Xandros123 » Mon Jun 15, 2009 5:02 pm

post-commit.php:
Code: Select all
<?php
   if (isset($argc))
   {
      define('BUGS2_INCLUDE_PATH', 'F:\Programmi\Apache\htdocs\thebuggenie\\');
      $author = $argv[1];
      $commit_msg = $argv[3];
      $new_rev = $argv[2];
      $old_rev = $new_rev - 1;
      $changed = $argv[4];
   }
   else
   {
      define('BUGS2_INCLUDE_PATH', '..\..\\');
      $commit_msg = urldecode($_REQUEST['commit_msg']);
      $new_rev = $_REQUEST['rev'];
      $old_rev = $new_rev - 1;
      $changed = $_REQUEST['changed'];
      $author = $_REQUEST['author'];
      $passkey = $_REQUEST['passkey'];
   }
   
   require BUGS2_INCLUDE_PATH . 'include\b2_engine.inc.php';
   require BUGS2_INCLUDE_PATH . 'include\ui_functions.inc.php';
   
   if (!isset($argc))
   {
      if ($passkey != BUGScontext::getModule('svn_integration')->getSetting('svn_passkey'))
      {
         echo 'incorrect passkey';
         exit();
      }
   }
   
   $fixes_grep = "#((bug|issue|ticket)\s\#?(([A-Z0-9]+\-)?\d+))#ie";
   
   $f_issues = array();
   
   if (preg_match_all($fixes_grep, $commit_msg, &$f_issues))
      {
      $f_issues = array_unique($f_issues[3]);

         $file_lines = preg_split('/[\n\r]+/', $changed);
         $files = array();

         foreach ($file_lines as $aline)
         {
            if (substr($aline, 0, 1) == ("A") || substr($aline, 0, 1) == ("U"))
            {
               $theline = trim(substr($aline, 1));
               $files[] = $theline;
            }
         }
         
         foreach ($f_issues as $issue_no)
         {
         $theIssue = BUGSissue::getIssueFromLink($issue_no, true);
         if ($theIssue instanceof BUGSissue)
         {
                                $uid = 0;
                                $crit = new B2DBCriteria();
                                $crit->addSel(B2tUsers::ID);
                                $crit->addWhere(B2tUsers::UNAME, $author);
                                $row = B2DB::getTable('B2tUsers')->doSelectOne($crit);
                                $uid = $row->get(B2tUsers::ID);
                        echo "-- ".$uid." --";
            $theIssue->addSystemComment('Issue updated from SVN', 'This issue has been updated with the latest changes from SVN.[quote]' . $commit_msg . '[/quote]', $uid, true);
            echo "-- ".$uid." --";
            foreach ($files as $afile)
            {
               $crit = new B2DBCriteria();
               $crit->addInsert(B2tSVNintegration::ISSUE_NO, $theIssue->getID());
               $crit->addInsert(B2tSVNintegration::FILE_NAME, $afile);
               $crit->addInsert(B2tSVNintegration::NEW_REV, $new_rev);
               $crit->addInsert(B2tSVNintegration::OLD_REV, $old_rev);
               $crit->addInsert(B2tSVNintegration::AUTHOR, $uid);
               $crit->addInsert(B2tSVNintegration::DATE, time());
               $crit->addInsert(B2tSVNintegration::SCOPE, BUGScontext::getScope()->getID());
               B2DB::getTable('B2tSVNintegration')->doInsert($crit);
            }
            echo 'Updated ' . $theIssue->getFormattedIssueNo() . "\n";
         }
         else
         {
            echo 'Can\'t find ' . $issue_no . ' so not updating that one.' . "\n";
         }
         }
      }
      return true;
?>


Note: change this path "F:\Programmi\Apache\htdocs\thebuggenie\\"
Xandros123
 
Posts: 4
Joined: Sat Jun 13, 2009 9:07 pm

Re: Subversion integration

Postby Xandros123 » Mon Jun 15, 2009 5:03 pm

Code: Select all
REM @echo off
echo -- START --
SET REV=%2
SET REPOS=%1

SET SVNLOOK=F:\Programmi\Subversion\bin\svnlook.exe
SET PHP=F:\Programmi\Php\php.exe

%SVNLOOK% log -r %REV% "%REPOS%" > COMMIT_MSG
REM SET THE COMMIT_MSG FROM THE FILE. The file is expected to contain only one line with this value
FOR /F "delims=" %%A IN (COMMIT_MSG) DO SET COMMIT_MSG=%%A
echo COMMIT_MSG=%COMMIT_MSG%

%SVNLOOK% changed -r %REV% "%REPOS%" > CHANGED
REM SET THE CHANGED FROM THE FILE. The file is expected to contain only one line with this value
FOR /F %%A IN (CHANGED) DO SET CHANGED=%%A
echo COMMIT_MSG=%CHANGED%

%SVNLOOK% author -r %REV% "%REPOS%" > AUTHOR
REM SET THE AUTHOR FROM THE FILE. The file is expected to contain only one line with this value
FOR /F %%A IN (AUTHOR) DO SET AUTHOR=%%A
echo COMMIT_MSG=%AUTHOR%

%PHP% -r "echo urlencode($argv[1]);" "%COMMIT_MSG%" > URL_COMMIT_MSG
REM SET THE URL_COMMIT_MSG FROM THE FILE. The file is expected to contain only one line with this value
FOR /F %%A IN (URL_COMMIT_MSG) DO SET URL_COMMIT_MSG=%%A
echo COMMIT_MSG=%URL_COMMIT_MSG%

%PHP% -f "F:\Programmi\Apache\htdocs\thebuggenie\modules\svn_integration\post-commit.php" "%AUTHOR%" "%REV%" "%COMMIT_MSG%" "%CHANGED%"

REM Add a pause to check the result
echo -- END --
REM pause


REM if you cannot run the command above either via ssh or locally, try using the url below.
REM remember to set the svn_passkey to something unique on the server, as the url is easily accessible from the outside.
REM wget --no-check-certificate "http://www.server.com/thebuggenie/modules/svn_integration/post-commit.php?passkey=svn_passkey&author=${AUTHOR}&rev=${REV}&commit_msg=${URL_COMMIT_MSG}&changed=${CHANGED}" -o /dev/null -O /dev/null


Note: set path correctly
Xandros123
 
Posts: 4
Joined: Sat Jun 13, 2009 9:07 pm

Re: Subversion integration

Postby dArignac » Tue Jul 14, 2009 3:02 pm

I tried your codes here as well as the code within the svn_integration module. It did not work for me, so I took your as inspiration and wrote a guide for using The Bug Genie 2 svn_integration module on Windows with VisualSVN Server: http://www.zoe.vc/2009/the-bug-genie-2-svn-integration-on-windows-with-visualsvn-server/
Maybe this helps some people.
dArignac
 
Posts: 1
Joined: Tue Jul 14, 2009 7:05 am

Re: Subversion integration

Postby Xandros123 » Tue Jul 14, 2009 3:07 pm

Can you explain me your problem with my solution please. I will try to fix it. Thaks.
Xandros123
 
Posts: 4
Joined: Sat Jun 13, 2009 9:07 pm


Return to Module problems

Who is online

Users browsing this forum: No registered users and 1 guest