baam
baam

Reputation: 1152

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.

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?

Upvotes: 0

Views: 1169

Answers (3)

baam
baam

Reputation: 1152

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

Upvotes: 1

Tom Russell
Tom Russell

Reputation: 1063

I had some trouble with this. There's no [components] section in the initial Trac.ini, and several different methods for enabling and adding repositories to your Trac environment are presented, leading one to believe that any one of them will suffice. I believe this not to be the case.

The successful actions for me were to:

  • Specify the following in the TracIni [versioncontrol] section:
    default_repository_type = 'git'
  • Add the missing [components] section to trac.ini:

    [components]
    tracopt.versioncontrol.git.* = enabled
    
  • Use the 'database' method and trac-admin to add the repository. Please note: 'git' is not yet "a valid type". Omit this final argument to the command:

    repository add <repo> <dir> [type]

Upvotes: 0

RjOllos
RjOllos

Reputation: 2934

You need to append .git to the repository_dir: repository_dir = /srv/git/myrepo. The issue has been fixed in #11297 for the forthcoming Trac 1.0.2. I also recommend against using the [trac] repository_dir option since it is deprecated and will be removed in the next major release of Trac #11703. You can configure your repositories in the database through the repository admin page or through the [repositories] section of trac.ini. See the TracRepositoryAdmin documentation for more information.

Please post your [logging] section settings if you continue to have trouble getting the logging to work. Keep in mind you need log_type set to file. The easiest way is to just set it from the admin panel.

Upvotes: 0

Related Questions