Indefero

Issue 172: indefero/src/IDF/Plugin/SyncGit/Serve.php on line 116

Reported by Stas SUSHKOV, Mar 31, 2009

Hi, I'm a student from Romania (Computer Science), and I liked a lot 
your project. So I thought setting up an indefero for my colleagues.

The problem I got is right in the title.
My setup was a little different from the one in READMEs. I 
completely changed the location in the file system of the pluf, 
indefero and git code repos (yes, we choose git).

So I obtain something like:
/var/www/vhost/pluf
/var/www/vhost/indefero
/var/www/vhost/www/ <- (the vhost document root)
/var/repositories <- (the git home and repo's)

I say that Serve.php was hardcoded with the git paths (/home/git) 
which is absolutely wrong imho. So I fixed the file in order to be 
able to use it independently from the git repository locations (I've 
attached my file).
Please test it, and if it it's ok, then I'm glad I could help.

Comment 1 by Stas SUSHKOV, Mar 31, 2009

Btw, the modifications will read the git repository location from 
`$_ENV` variable, so consider this when setting up the `$cfg` git 
repository location!

In my example `/var/repositories` is the home folder of the user git 
in my system, and that path corresponds to the settings in my  
`idf.php` file.

Comment 2 by Loïc d'Anterroches, Mar 31, 2009

As you can see here: src:src/IDF/Plugin/SyncGit/Serve.php line 116:

 chdir(Pluf::f('idf_plugin_syncgit_git_home_dir', '/home/git'));

This means, take the Git home dir from the 
'idf_plugin_syncgit_git_home_dir' configuration variable in the 
idf.php file, and if not set, default to '/home/git'. So just 
putting:

 $cfg['idf_plugin_syncgit_git_home_dir'] = '/var/repositories';

in your configuration file will solve your problem. Please tell me 
if this does not work.
Status: WontFix

Comment 3 by Stas SUSHKOV, Apr 1, 2009

I added this to my idf.php
---
//$cfg['idf_plugin_syncgit_git_home_dir'] = '/var';
// And even with this it is not working
$cfg['idf_plugin_syncgit_git_home_dir'] = '/var/repositories';
$cfg['idf_plugin_syncgit_base_repositories'] = '/var/repositories';
---

But all I got is:
---
git push --all
mkdir(): File exists
fatal: The remote end hung up unexpectedly
---

So I switched to my patched version.
Thanks for help.

Comment 4 by Loïc d'Anterroches, Apr 1, 2009

I keep this issue closed but keep in mind this mkdir issue. It is 
not normal, I will review the code for it next time I am going 
through. 

Thanks a lot for your time and friendliness.

Comment 5 by Jose Luis Rivas, May 11, 2009

I get the same mkdir(): File exists issue. I, as Stas, used 
different layout that the suggested and had to change the hardcoded 
/home/git to my /srv/git and you uploaded one project, with the 
second and third and so on I got the mkdir(): File exists, only with 
the first project I can upload and update.

I tried Stas's patch but there's some error with mysql and I 
"get mysql_real_escape_string() expects parameter 1 to be 
string, array given" with any project

Regards

Comment 6 by Jose Luis Rivas, May 11, 2009

Ok, I'm now uploading with the Stas's patch, now there's no mysql 
issue.

I believe you should push this to master, it worked for me and I 
believe is really a problem

Comment 7 by Jose Luis Rivas, May 11, 2009

Me again, it pushes to git-repository path but doesn't shows on 
InDefero web interface the changes and pushes...

Comment 8 by Stas SUSHKOV, May 11, 2009

You should consider the fact that the patch was NOT tested with the 
latest upstream changes!!!

The second thing is that your repository directory is read from 
shell ENV! So the target will be pushed to home directory's root.

In explanation to what I wrote above:
adduser git 
...bla bla...
...the user is created with the home folder /home/git let's say...

Indefero will see /home/git/newrepo.git as the target path for the 
projects!
So you should check the path which is read by php in ENV of the user 
git (or what user you're using) to correspond to the indefero web 
settings.

Comment 9 by Jose Luis Rivas, May 12, 2009

Well I've this on my idf.php
--
$cfg['git_repositories'] = '/srv/git/repositories/%s.git';
$cfg['git_remote_url'] = 'git://git.rivco.net/%s.git';
$cfg['git_write_remote_url'] = 'git@git.rivco.net:%s.git';
$cfg['idf_plugin_syncgit_git_home_dir'] = '/srv/git/repositories';
$cfg['idf_plugin_syncgit_base_repositories'] = 
'/srv/git/repositories';
$cfg['idf_plugin_syncgit_path_gitserve'] = 
'/opt/indefero/scripts/gitserve.py';
$cfg['idf_plugin_syncgit_path_authorized_keys'] = 
'/srv/git/.ssh/authorized_keys';
$cfg['idf_plugin_syncgit_sync_file'] = '/tmp/SYNC-GIT';
--

I reinstalled all so I'm using SyncGit/Serve.php without Stas's 
patch and now I believe is not necessary since I think I found the 
issue. I created a project in my brand new InDefero and I got:

--
mkdir(): File exists
fatal: The remote end hung up unexpectedly
--

Then I ran gitcron.php and everything uploaded OK. To check if this 
was the cause I followed this steps several times with all my 
projects

Right now I'm running gitcron.php more often, every minute. Is there 
another way to avoid this?

I believe if you're not willing to fix this then it should go to the 
FAQ :)

Anyway in the process I found yet another issue while using commands 
with -- like git push origin --tags and --all but I'll fill it in 
another ticket since I believe maybe there's a way to fix the issue 
with gitcron.php

I hope this helps,
Regards.

Comment 10 by Stas SUSHKOV, May 12, 2009

After 
`usermod -d /srv/git/repositories git`
it should be working.
---
Here's my setup:
# GIT
$cfg['git_home'] = '/var/repositories/';
$cfg['git_repositories'] = '/var/repositories/%s.git';
$cfg['git_remote_url'] = 'git://domain.tld/%s.git';
$cfg['idf_plugin_syncgit_path_gitserve'] = 
'/var/www/vhost/indefero/scripts/gitserve.py'; # yes .py
$cfg['idf_plugin_syncgit_path_authorized_keys'] = 
'/var/repositories/.ssh/authorized_keys';
$cfg['idf_plugin_syncgit_sync_file'] = '/tmp/SYNC-GIT';
#$cfg['idf_plugin_syncgit_git_home_dir'] = '/var';
#$cfg['idf_plugin_syncgit_base_repositories'] = '/var/repositories';

Where:
$ grep -i git /etc/passwd
git:x:110:119:Git Version Control,,,:/var/repositories:/bin/sh

This is it.

Created: 4 years 1 month ago by Stas SUSHKOV

Updated: 4 years 9 days ago

Status: WontFix

Followed by: 2 persons

Labels:
Type:Defect
Priority:Medium