Domanda

Windows + VisualSVN Server + Trac 0.12

I want, that tickets automatic close, when commit text have "close #2" (or other command, all the same)

È stato utile?

Soluzione

Well my friend you are in luck becuase I finally figured out how to do this. I have the same configuration as you, Windows + VisualSVN + Trac. This is what I have gathered and put together from a bunch of places on the net and my experience. Here we go.

  1. Install VisualSVN.

  2. Create (import...) your repository. Just make sure it is there and working properly with VisualSVN. We will call your project TheProject. And say it is located in PathToSVN. Which means if project is in C:\SVN\TheProject. Then PathToSVN is C:\SVN

  3. Make sure you have at least one user if you use Subversion authentication.

  4. Download VisualSVN Trac add-on from: http://www.visualsvn.com/files/VisualSVN-Server-2.5.4.28066-Trac-0.12.3.zip.
    N.B. Check http://www.visualsvn.com/server/trac/ if there is a newer version but come back and follow the instructions here. Not the ones there.

  5. Unzip it to %VISUALSVN_SERVER% folder (your VisualSVN installation folder)

  6. Create a folder somewhere for you Trac. e.g. C:\Trac or D:\Trac. We will call it PathToTrac\

  7. Allow "Full Control" access to PathToTrac\ folder for built-in Network Service account (or other account that is used to run VisualSVN Server's service).

  8. Open the command prompt and execute the command

    "%VISUALSVN_SERVER%trac\trac-admin.bat" PathToTrac\TheProject initenv

    Use the default settings. Just press enter for all questions.

  9. Execute the following command to add TheProject Subversion repository to the Trac:

    "%VISUALSVN_SERVER%trac\trac-admin.bat" PathToTrac\TheProject repository add TheProject PathToSVN\Project svn

  10. If you don't have python already, Add system variable: PYTHONHOME=%VISUALSVN_SERVER%trac\python

    Just make sure PYTHONHOME points to somewhere where we can find python. And look out for spaces at the end of the path. Windows doesn't like it.

  11. Add the following text to file %VISUALSVN_SERVER%conf\httpd-custom.conf if you use Subversion authentication:

    LoadModule python_module "trac/python/mod_python_so.pyd"
    LoadModule authz_user_module bin/mod_authz_user.so
    <Location /trac>
      SetHandler mod_python
      PythonInterpreter main_interpreter
      PythonHandler trac.web.modpython_frontend
      PythonOption TracEnvParentDir PathToTrac
      PythonOption TracUriRoot /trac
    
      AuthName "Trac"
      AuthType Basic
      AuthBasicProvider file
      AuthUserFile "PathToSVN/htpasswd"
    
      Require valid-user
    </Location>
    

or this text if you use Windows authentication:

    LoadModule python_module "trac/python/mod_python_so.pyd"
    LoadModule authz_user_module bin/mod_authz_user.so
    <Location /trac>
      SetHandler mod_python
      PythonInterpreter main_interpreter
      PythonHandler trac.web.modpython_frontend
      PythonOption TracEnvParentDir PathToTrac
      PythonOption TracUriRoot /trac

      AuthName "Trac"
      AuthType VisualSVN

      # Set the option's value to on if Windows Basic Authentication
      # is enabled, otherwise set it to off.
      AuthnVisualSVNBasic on

      # Set the option's value to on if Windows Integrated Authentication
      # (available in the Enterprise Edition) is enabled, otherwise set it to off.
      AuthnVisualSVNIntegrated on

      require valid-user
    </Location>

MAKE SURE to replace PathToSVN and PathToTrac with the proper paths. In the texts

  1. Restart VisualSVN server. Note down the port where the server is listening at.

  2. Open "http://localhost:port/trac/" If you can see the Trac for your repository you are almost done. Otherwise go back and check if you have missed anything.

  3. Go to your SVN directory and then to your project. PathToSVN\TheProject. e.g. C:\SVN\FirstProject. And you will find a folder name hooks. And in that folder you will find a file name post-commit.cmd. If it is not there then create it.

  4. Add this to post-commit.cmd (just open it with a text editor) and save it.

    @set PATH=%PYTHONHOME%;%PATH%
    
    @set REPOS="%1"
    @set REV="%2"
    @set TRAC_ENV="PathToTrac\TheProject"
    
    @for /F %%A in ('svnlook author -r "%REV%" %1') do set AUTHOR=%%A
    @for /F "delims==" %%B in ('svnlook log -r "%REV%" %1') do set LOG=%%B
    
    @call "%VISUALSVN_SERVER%trac\python\python.exe" "PathToSVN\TheProject\hooks\trac-post-commit-hook" -p "%TRAC_ENV%" -r "%REV%" -u "%AUTHOR%" -m "%LOG%"
    
  5. Download the trac-post-commit-hook file from http://trac.edgewall.org/attachment/wiki/TracMultipleProjects/ComprehensiveSolution/trac-post-commit-hook. Just go to the bottom of the page and click download original. Save it in PathToSVN\TheProject\hooks directory. It should be named trac-post-commit-hook no extension.

  6. Now go to PathToTrac\TheProject\conf directory and open the file trac.ini. Search for repository_dir. Add tht path to your repository as it's value e.g.

     repository_dir = PathToSVN\TheProject
    
  7. You are Done!!!

  8. Now you can close or reference tickets directly from your commits like, fixes #1, closes #1 ... Read the comments in the trac-post-commit-hook file

Altri suggerimenti

Trac's official documentation includes a section on automatically updating tickets based on commit messages. Make sure you follow both sets of instructions (one to set up the CommitTicketUpdater plugin, and one to add the hook scripts).

Are you looking for general advice, or do you have a specific question?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top