Search code examples
gittrac

Trouble with a git bare repository after upgrading trac from 0.11 to 0.12


I just recently upgraded my Trac system so we could handle multiple repositories. I started getting some browser errors and tracked it down to GitPlugin (when I disable it all of the errors go away, though of course my version control tracking does too).

On every page I get:

'Warning:  Error with navigation contributor "BrowserModule"'

and on the timeline page I get:

 Trac detected an internal error:

TypeError: 'NoneType' object is unsubscriptable

The Log gives me this for the timeline page out of 'main':

Internal Server Error: Traceback (most recent call last): File "/usr/local
/lib/python2.6/dist-packages/Trac-0.12-py2.6.egg/trac/web/main.py", line 513, in 
_dispatch_request dispatcher.dispatch(req) File "/usr/local/lib/python2.6/dist-packages
/Trac-0.12-py2.6.egg/trac/web/main.py", line 235, in dispatch resp = 
chosen_handler.process_request(req) File "/usr/local/lib/python2.6/dist-packages/Trac-
0.12-py2.6.egg/trac/timeline/web_ui.py", line 142, in process_request available_filters += 
event_provider.get_timeline_filters(req) or [] File "/usr/local/lib/python2.6/dist-packages
/Trac-0.12-py2.6.egg/trac/versioncontrol/web_ui/changeset.py", line 861, in 
get_timeline_filters repositories = rm.get_real_repositories() File "/usr/local
/lib/python2.6/dist-packages/Trac-0.12-py2.6.egg/trac/versioncontrol/api.py", line 588, in 
get_real_repositories repos = self.get_repository(reponame) File "/usr/local/lib/python2.6
/dist-packages/Trac-0.12-py2.6.egg/trac/versioncontrol/api.py", line 526, in 
get_repository repos = connector.get_repository(rtype, rdir, repoinfo.copy()) File 
"/usr/lib/python2.6/dist-packages/tracext/git/git_fs.py", line 159, in get_repository 
shortrev_len=self._shortrev_len) File "/usr/lib/python2.6/dist-packages/tracext
/git/git_fs.py", line 177, in __init__ Repository.__init__(self, "git:"+path, None, log)
 File "/usr/local/lib/python2.6/dist-packages/Trac-0.12-py2.6.egg/trac/versioncontrol
/api.py", line 730, in __init__ self.reponame = params['name'] TypeError: 'NoneType' 
object is unsubscriptable

and this for all pages out of 'Chrome':

Error with navigation contributor BrowserModule: TypeError: 'NoneType' object is unsubscriptable

I set up a few test environments before upgrading this system and they both worked with multi repositories and git, but with 2 key differences: they started as 0.12 and the repositories are not bare repositories.

My question is this: Did I mess something up when upgrading and need to start from a fresh environment, do I need to switch my repositories to non-bare, or am I missing something completely and need to do something else?


Solution

  • All right, so I've managed to get a functioning work around.

    Go into the server and create a new directory.

    git clone the bare remote repository in that new directory.

    go into the old repository and change the post-receive hook (under .git/hooks) to be:

    #!/bin/sh
    pushd /path/to/new/repo > /dev/null
    unset $(git rev-parse --local-env-vars)
    git pull -q
    popd > /dev/null
    

    If there is no post-receive just create a file with that file name.

    Now go to your trac.ini and point any repository references to the new repository directory and poof! it works.

    Note: the people who are pushing still push to the old repository. This script merely calls a pull from the "new" repository.