Skip to content

script to make Trac (bug database) and git (source control) work together via Trac-API

License

Notifications You must be signed in to change notification settings

ThESCOM/git-trac-hook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

             ,
         -  /|
        -  / |
      -   /o |
   ~^~ ^~//-'|~^~ ~^~
    ~^~.-->>---. ~^ ~^~
   ~^~ `"""""""` ^~^ ~^
    ~^~ ~^ ~^~^ ~^~^ ~^
    Max Oberberger
    github@oberbergers.de
    https://github.com/chiemseesurfer/git-trac-hook

Copyright © 2012-2013 Max Oberberger

This files are free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.


Table of Contents

  1. Introduction

  2. System Requirements

  3. Installation

  4. Using git-trac-hook

  5. References

  6. Introduction =============== If you are using git [1] for source control and Trac [2] including GitPlugin for bug tracking, then the git-jira-hook script might be useful to you.

Once you have the script setup in your environment, every time you make a git commit, a comment is automatically posted to an open issue in Trac.

  1. System Requirements ===============
  1. Installation =============== Here is a typical example of how this hook may be used.

In a corporate setting where git is used, there is typically an "upstream" or "public" repository. And then developers have their "private" repositories. For their day-to-day work, the developers use their private repositories. Periodically, they (either directly, or via gatekeepers) push changes from their private repository to the "upstream" one. Also, the "upstream" repository is typically a bare repository, and no actual commits are done here.

In the private repository, the hook should be installed, but only partically. Every time a commit is made, the hook only checks to make sure that the commit text conforms to correct formatting (i.e. the magic references to Trac issues are present). No Trac issues are updated.

The hook is completely installed in the "upstream" repository.

Whenever a commit is made in the upstream repository or a "git push" is done to it, the installed hook will kick in and validate the commit message, followed by update of the Trac issue.

3.1 Installation for "upstream" repository

  • Copy this script to /hooks/{pre-receive|post-receive} and mark it executable

    Example:

      cp git-trac-hook upstream-project.git/hooks/post-receive
      cp git-trac-hook upstream-project.git/hooks/pre-receive
      chmod a+x upstream-project.git/hooks/post-receive
      chmod a+x upstream-project.git/hooks/pre-receive
    
  • Set the following git config values in the bare repository:

      git config trac.env /path/to/your/trac/environment
      git config trac.admin /path/to/your/trac-admin
    

    Example:

      git config trac.env /usr/local/trac/myTrac
      git config trac.admin /usr/local/bin/trac-admin
    
  1. Using git-trac-hook =============== When you are read to make a git commit, make sure that you have an appropriate open trac issue.

Anywhere in your commit message, you must put the following strings (without the quotes): "refs #23" "refs #1" "fixes #8"

If you want to commit things not according to a trac-ticket, you can use "#noref" With this tag, no trac issue update will be done.

And then you do a "git push" to push your changes upstream, the trac issue update will be done.

A complete list of all tags which are available

  • close
  • closed
  • closes
  • fix
  • fixed
  • fixes
  • references
  • refs
  • addresses
  • re
  • see
  • #noref
  1. References =============== [1] Git, an source configuration management ("SCM") tool http://git-scm.com/

[2] Trac, a bug tracking system http://trac.edgewall.org

[3] Trac, Git Plugin https://github.com/hvr/trac-git-plugin http://trac-hacks.org/wiki/GitPlugin

About

script to make Trac (bug database) and git (source control) work together via Trac-API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages