Changes between Version 37 and Version 38 of GitPlugin


Ignore:
Timestamp:
Feb 28, 2010, 11:39:36 PM (5 years ago)
Author:
anonymous
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GitPlugin

    v37 v38  
    9797}}}
    9898
     99=== post-receive hook scripts ===
     100
     101For Trac 0.11 see attachments below.
     102
     103With Trac 0.12 a VC independent plugin approach to handling ticket references in commit messages has been put into place.
     104Thus for 0.12 in you basically need to enable the CommitTicketUpdater component in `trac.ini`, and call `trac-admin TRAC_ENV changeset added <commitid(s)>`, e.g. by using a `post-receive` script along the lines of:
     105{{{
     106#!python
     107#!/usr/bin/env python
     108
     109import sys
     110from subprocess import Popen, PIPE, call
     111
     112GIT_PATH = '/usr/bin/git'
     113BRANCHES = ['master']
     114TRAC_ENV = '/srv/trac/myproj'
     115REPO_NAME = '(default)'
     116
     117def call_git(command, args):
     118    return Popen([GIT_PATH, command] + args, stdout=PIPE).communicate()[0]
     119
     120def handle_ref(old, new, ref):
     121    # If something else than the master branch (or whatever is contained by the
     122    # constant BRANCHES) was pushed, skip this ref.
     123    if not ref.startswith('refs/heads/') or ref[11:] not in BRANCHES:
     124        return
     125
     126    # Get the list of hashs for commits in the changeset.
     127    args = (old == '0' * 40) and [new] or [new, '^' + old]
     128    pending_commits = call_git('rev-list', args).splitlines()[::-1]
     129
     130    call(["trac-admin", TRAC_ENV, "changeset", "added", REPO_NAME] + pending_commits)
     131
     132if __name__ == '__main__':
     133    for line in sys.stdin:
     134        handle_ref(*line.split())
     135}}}
     136
    99137== Help ==
    10013812/13/2009