Search code examples
gittrac

How can I link Trac with Git?


I am trying to set up Trac 1.0.1 with git on CentOS 7.
Trac is running fine but I am not able to link a Git repository with Trac.

Here is what I've done so far:

yum install git
adduser git
mkdir -p /srv/git/myrepo
cd /srv/git/myrepo
git --bare --shared=true init
chown -R git:git -R /srv/git/myrepo

At this point I am able to clone and checkin changes from a client.
Now I want to browse the source files via trac. Here I've changed the Trac.ini like this:

repository_type = git
[components] 
tracopt.versioncontrol.git.* = enabled

If I understand correctly, I now have two options to add the repository.

  • Directly in the Trac.ini file

    repository_dir = /srv/git/myrepo
    
  • or via the admin panel in the menu 'repositories'

If I add the repo directly in the trac.ini config-file I get the following error:

Warning: Can't synchronize with repository "(default)" (/srv/git/myrepo does not appear to be a Git repository.). Look in the Trac log for more information.

The problem here is, that there is no log file, although it's set in the trac.ini to debug and to trac.log. If I add the repo via the admin panel, I get no errors but there is also no browse tab.

What am I doing wrong?


Solution

  • Here again, the problem was SELinux.

    chcon -R -t httpd_user_content_t /srv/git fixed the problem.

    More information about Trac and SELinux: http://trac.edgewall.org/wiki/TracWithSeLinux