Update the Git repository automatically
The Wiki suggests (http://www.redmine.org/wiki/redmine/RedmineRepositories) that you should set up a cron job to update the Git bare repository, the one redmine points to, automatically. This is unneccessary since you could just as easily use Git's hooking mechanism to have it automatically update the repo on each push.
1. chmod a+x post-receive-redmine
2. Put post-receive-redmine in <redmine dir>/doc/git-hooks
3. Change into your main git repo dir (the one you push to)
4. Edit ./hooks/post-receive and add a line that says ". <redmine dir>/doc/git-hooks/post-receive-redmine"
5. Run "git config --add hooks.redmineGitBase <base path to redmine bare repos, i.e. /var/lib/redmine/git_repos>"
6. You're done!
The script could be updated to create the bare repo if it doesn't already exist but it would need to know which permissions to change it to for redmine to read it so I didn't add this feature.
Updated by David Holm over 15 years ago
Note that the post-receive-redmine script is executed with the permissions of the commiter so that person has to have write access to the redmine bare repo in order for the git push to succeed.
I have an "rnd" group where everyone in R&D belongs so I did:
setfacl -d -m g:rnd:rwx /var/lib/redmine/git_repos
Updated by Radomir Mladenovic almost 15 years ago
Thanks for the script! It's exactly what I needed. I still don't understand why push works but fetch called from the redmine repo doesn't (at it looks as a natural thing to do) but... I'm quite fresh with git.
In my case main git repo dir has a suffix ".git" (e.g. /var/git/repositories/internal/test.git) but redmine bare clone not (e.g. /var/git/checkout/internal/test) so I made a small modification to your script to remove the suffix. (It's attached.)
Also, it wasn't clear to me from your post that "hooks.redmineGitBase" should point to the parent of redmine repos directory (e.g. /var/git/checkout/internal in my case). If multiple repositories have the same base (as they probably do) it may be worth to set this property on a global level.
Updated by L Philbrook about 14 years ago
I added bare repo creation via ssh or file and the ability to set a global redmineGitBase from within the script. I also added some additional validation. This is against Radomir v2, so .git is removed in the cloned repo.
Updated by Anonymous almost 11 years ago
However, what should be fixed is the plethora of different guides for repository access which mention different methods, but don't mention the WS API key. It is very difficult to navigate this jungle and find the "correct" information... Perhaps a single "official" guide should be created, and all the other guides should be augmented with a header pointing to the official guide, and stating that these other guides may work, but may also be updated, and should be used with caution...
Updated by Daniel Felix almost 11 years ago
- Due date set to 2013-04-01
- Status changed from New to Needs feedback
Well I'm not sure if this one could be really closed. This is another approach to update the repo.
I would tend to close this issue too, but I would like to give the community the chance to give feedback on this.
I set this issue to needs feedback and will close it on 1th April if there is no feedback which tends to the other side.
For your purpose of a global handbook,... This sounds like a good idea. I'm not sure how we should do this, but maybe I get a good concept the next days. :-)