bloghow2doitde

A blog about computer science and a life between Heidelberg and Munich

Nowadays git is the Tool of choice when it comes to collaboration and source code management. But projects often need more than that: there are lists of features to implement, bug reports and patches to integrate in the source. So it is natural that there is another tool to manage all that stuff.

My projects are using gitolite and Redmine as Frontend to those repositories.

Redmine is currently not able to access other than local git repositories. This is quite a problem as Redmine is not able to browse through repositories within the local file-system. So there is no other way to mirror the repository. This can be done my a post-receive hook in gitolite. But first we have to create the mirror.

1
2
3
4
cd /path/to/mirror-repo.git
git clone --mirror /path/to/repo.git/
git config --add core.sharedRepository 0666
chown gitoliteUser:gitoliteUser /path/to/mirror-repo.git -R

Do not forget to setup the correct rights as without them git will not be able to synchronize the mirror and Redmine will not see any changes we made (or even no repository at all). Of course this depends on your setup. For exmaple if Redmine is running as a dedicated user one could imagine to use more restrictive rights. One could add the user of Redmine into the group of the gitolite user. This is what I have done and due to this it works without global read/write permissions.

However, if we’re done with the initial mirroring we’re able to place our hook within the gitolite repository.

/path/to/repo.git/hooks/post-receive
1
2
#!/bin/sh
/usr/bin/git push --mirror /path/to/mirror-repo.git

So every time one pushes a commit the hook will be called and the local mirror will get his updates. Don’t forget to set the correct rights for the post-receive file as it has be owned by the user gitolite is using and should be only writable for gitolite.

Now you’re able to use the path of the mirror repository in Redmine and browse through it and use all the features of Redmine. But let’s hope that Redmine will be able to avoid such “drity” solutions one day.

See changes instantly on activity page of a Redmine project

If you would like to see the changes you have made instantly and without clicking on the repository tab you have to add a line. The easiest way to do this is to simply call rake with a pre-defined function of Redmine.

/path/to/repo.git/hooks/post-receive
1
2
3
#!/bin/sh
/usr/bin/git push --mirror /path/to/mirror-repo.git
/usr/bin/rake -f /path/to/redmine/Rakefile RAILS_ENV=production redmine:fetch_changesets

By adding this line to your post-hook you are calling the redmine:fetch_changesets target as Redmine itself is doing to fetch the changesets in it’s repositories.

posted in: Linux, Redmine, git, gitolite