Movatterモバイル変換


[0]ホーム

URL:


Edgewall Software
Trac
wiki:TracGit

Context Navigation


Git support in Trac

Note: If you came to this page looking for the URL of the git repository for Trac, seeTracRepositories instead.

Since version1.0, Trac features built-in support forGit as aVersionControlSystem for Trac.

Please note that we still consider the level of performance to be sub-optimal, so it might not work for you. Small to medium sized repositories should be handled reasonably well, however.

Features

  • Browsing source code via theTracBrowser
  • Viewing the change history of a file or directory usingTracRevisionLog
  • Performing diffs between any two files or directories
  • Displaying changes in theTracTimeline
  • (Optionally) cachingTracChangeset information in Trac's database
  • Caching Git commit relation graph in memory
  • Search change descriptions viaTracSearch
  • Annotation support, also known as "blame" operation
  • Interpretation of hex-strings in wiki content as sha1 commit checksums, with a configurable minimum character width

Git

Download and Installation

You need to have thegit command line tools installed. You can download Git itself fromGit:Download.

We try to maintain backward compatibility with versions of Git from 1.5.6 to the latest.It's better use a recent version, however.

Configuration

The configuration has to be done mainly on the Trac side, there's nothing required to do on the Git repository side.Some advanced use cases necessitate however to install apost-receive hook in the Git repository (seebelow).

Note that the repository should be made accessible as a local repository. Thanks to the distributed nature of Git, that's always possible. If the repository is not already local, simplygit clone it.

Trac

The Trac Git support is included with Trac since 1.0 as an optional component:tracopt.versioncontrol.git.

You simply have to explicitlyenable the plugin inTracIni:

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

The web administration interface can also be used for this,using theGeneral / Plugins panel.

Setting up a Trac environment

You can either reuse an existing Trac environment,or create a brand new one.

New environment

For general instructions, seeTracInstall.

When creating a new environment withTracAdmininitenv command,

  • for therepository type, specifygit instead of the defaultsvn.
  • for therepository directory, specify the location of the Git repository(for Trac < 1.0.2 the path of a non-bare repository must end in a.git directory).

Your<trac_environment>/conf/trac.ini configuration fileshould have a[trac] section similar to the following (Trac < 1.1.3):

[trac]repository_type=gitrepository_dir=/path/to/my/git/repository/.git

or a[repositories] section similar to the following (Trac 1.1.3 and later).

[repositories].type=git.dir=/path/to/my/git/repository/.git

Specify the location of thegit executable, in case it's not the default/usr/bin/git. As an example, for Windows:

[git]git_bin=C:/Dev/msysgit/bin/git.exe

See also#settings below.

Adding a Git repository to an existing environment

If all you need is to work with a single git environment, it is enoughto modify the[repositories] section in yourtrac.ini so that itcontains the appropriate values for the.type and.dir options, like in the above example.

However, if you need more than one git repository, or if you want to keep your old Subversion repository as the default repository in orderto not break theTracLinks pointing to source files and changesets contained in that repository, you can add non-default repositories.

There are basically two ways to do that, either via the[repositories] section of theTracInifile, or via the web administration interface using theVersion Control / Repositories panel.For more details, see theTracRepositoryAdmin.

Fine tunetrac.ini settings

Besides thegit_bin setting discussed above, there are a few more Git specific settings that can be specified inTracIni [git] section.

Setting up post-receive hooks

If you want to benefit from some advanced features for your repository,like automatically update your tickets based on the content of the commitmessages (CommitTicketUpdater) or smart caching, then you need to createor modify thepost-receive hook in the.git/hooks repository so that it callstrac-admin repository appropriately.

enable post-receive hook functionality on your repository, put a post-receive script intoyour_repository/.git/hooks/.

TODO Include post-receive scripts attached toth:GitPlugin#post-receivehookscripts

You can then enable theCommitTicketUpdater functionality in yourtrac.ini by adding:

tracopt.ticket.commit_updater.*=enabled

to the[components] section.

Troubleshooting

  • Don't forget to enable the plugin:
    [components]tracopt.versioncontrol.git.*=enabled
  • For Trac < 1.0.2, therepository_dir in the configuration section needs to be the.git repository directory (i.e. the one containing the fileHEAD andconfig), not the working tree directory that holds the.git folder (#11297). However, abare repository will have these control files in the top-level directory and will not contain a.git directory.
  • Wrong permissions may also be the cause of the errorGitError: GIT control files not found, maybe wrong directory?. Make sure the repository path is accessible via git by thetracd process.
  • For Trac < 1.0.6, a repository with many branches makes Trac slow (#11971).
  • For Trac < 1.0.2, the source browser can throw an error when trying to kill a git log process; it's not clear why it should be an error for the process to have completed. This problem manifests as a stack trace with terminate_nix at the end (#10958).
  • For Trac < 1.0.5,git processes can stay open forever like this with bitten-slave (#11973).
    /usr/bin/git --git-dir=/path/to/git log --pretty=format:%n%H --name-status 324a8d5... --...

Known Issues

#10666
Setting fine grained permissions using AuthzPolicy does not work
#11061
TypeError: Git object id must be byte or a text string, not: int
#11992
Allow git commit hashes to be abbreviated to 7 characters
#13169
GitNode.get_content() read entire of a file into memory even if it is huge

History

The Git support was initially developed as a plugin by Herbert Valerio Riedel for Trac 0.10-0.13. SeeTracHacks:GitPlugin /GitHub. Since Trac 1.0 it has now been included as an optional component (#10594), and is maintained and developed with Trac.

Last modified2 years ago Last modified on Feb 26, 2023, 9:09:07 AM

Attachments(1)

Download all attachments as:.zip

Note: SeeTracWiki for help on using the wiki.

Download in other formats:


Trac Powered

Powered byTrac 1.4.3
ByEdgewall Software.

Visit the Trac open source project at
https://trac.edgewall.org/

info@edgewall.com

Copyright © 2003-2024 Edgewall Software. All rights reserved.


[8]ページ先頭

©2009-2025 Movatter.jp