Radek
Radek

Reputation: 11121

auto update git repos in redmine

I want to have git repos accessable in redmine. But what about auto update of redmine git repos. I thought redmine will 'read' git repos but it wants to have its own local copy. So then the question of having the latest repo in redmine arises.

I found few solutions using cron but I would prefer to use git hook if possible. Any idea how to make git if there is repository update to also update redmine repository?

redmine wiki provides this solution but I do not understand what it does. Maybe it is what I want? Could somebody explain below code?

echo "Post receive-hook => updating Redmine repository" 
sudo -u my_redmine_user -p secret perl -we '`cd /redmine/repositories/my_repo.git && git fetch && git reset --soft refs/remotes/origin/master`'

Upvotes: 1

Views: 2873

Answers (1)

Cascabel
Cascabel

Reputation: 497532

That looks like it's meant to be placed in the post-receive hook of your central repo. That hook is executed whenever you push into the repo, so it's an ideal place to trigger other operations like this one. (Of course, the post-update hook would also be a reasonable place.)

The hooks are, surprise, in the hooks directory of a bare repo (.git/hooks for a non-bare repo). If you don't already have a post-receive hook, you can just create one: make a file called post-receive in the hooks directory, make it executable, put #!/bin/sh on the first line, then those two lines. If there is already one, just add those two lines to it. Since post-receive is meant mainly for notification-type operations, it's pretty easy for the script to end up being a list of things like this.

Upvotes: 4

Related Questions