Edgewall Software

Extension Point : IRepositoryProvider


The IRepositoryProvider allows components to enumerate version control repositories to be made available in Trac.


Trac can be connected to Version Control systems to e.g. browse files, visualize changesets or revision logs. Plugins can hook into the version control system to extend the set of repositories that are available in Trac.

The main purpose for this interface is to allow plugins to implement new mechanisms to register, configure or auto-discover repositories.

(For implementing the actual mechanism that connects to a new type of repository use IRepositoryConnector instead.)


Implementing the interface follows the standard guidelines found in TracDev/ComponentArchitecture and of course TracDev/PluginDevelopment.

Trac automatically calls the get_repositories method to retrieve a list of dictionaries. Each dictionary represents a repository to connect to. The dictionaries dictionary which must contain at the very least either of the following entries:

  • 'dir': the repository directory which can be used by the connector to create a Repository instance. This defines a "real" repository.
  • 'alias': the name of another repository. This defines an alias to another (real) repository.

Optional entries:

  • 'type': the type of the repository (if not given, the default repository type will be used).
  • 'description': a description of the repository (can contain WikiFormatting).
  • 'hidden': if set to 'true', the repository is hidden from the repository index.
  • 'url': the base URL for checking out the repository.

Trac caches the list of repositories. You can call RepositoryManager(self.env).reload_repositories() to invalidate the cache and load the new list of repositories, e.g. if your plugin deletes or creates a new repository.


GitwebProjectsRepositoryProvider provides all Git repositories listed in your Gitweb-formatted projects.list file.

Alternatively, you might simply want all the subdirectories of one parent directory to get auto-discovered as Git repositories:

import os
from trac.config import PathOption
from trac.core import Component, implements
from trac.versioncontrol.api import IRepositoryProvider

class DirGitRepositoryProvider(Component):

    projects_base = PathOption('git', 'projects_base', doc=
        """Path to the base of your git projects""")

    def get_repositories(self):
        for name in os.listdir(self.projects_base):
            repo = {
                'dir': os.path.join(self.projects_base, name),
                'type': 'git',
            yield name, repo

Available Implementations

  • trac.versioncontrol.api.DbRepositoryProvider: Provides repositories registered in Trac DB.
  • trac.versioncontrol.api.RepositoryManager: Provides repositories registered in [repositories] section of trac.ini.
  • tracopt.versioncontrol.git.git_fs.GitwebProjectsRepositoryProvider: Provides repositories registered in a Gitweb-formatted projects.list file.

Additional Information and References

API History

  • 0.12 introduced the interface
Last modified 3 years ago Last modified on Jul 30, 2014, 11:59:45 AM
Note: See TracWiki for help on using the wiki.