I have this
location ~ ^.*user/repo\.git\/(HEAD|info/refs|objects/info/.*|git-upload-pack)${
//send to fastcgi_param SCRIPT_FILENAME /usr/bin/gitolite-shell;
}
This is working for clone. I have modified Gitolite so I can make public repos without key or http user/password.
Now when I want to push info/refs get matched against this route and I can not move on to the next location that is responsible for push.
location ~ ^.*user/repo\.git\/(HEAD|info/refs|objects/info/.*|git-receive-pack)${
//some custom auth and so on
}
Btw, this is working in apache for push on public repos:
<LocationMatch "^/username/repo/git-receive-pack$">
</LocationMatch>
Bottom line is that:
^.*user/repo\.git\/(HEAD|info/refs|objects/info/.*|git-upload-pack)$
^.*user/repo\.git\/(HEAD|info/refs|objects/info/.*|git-receive-pack)$
are problem since first will always catch second.
I tried to do some
if ($args = "service=git-receive-pack"){
//do redirect to user/repo.git/git-receive-pack but that will not work since
//info/refs?service=git-receive-pack must be called first.
}
I need help with regex and do not forget that you can not match location query string in Nginx location. For example
user/repo.git/info/refs?service=git-receive-pack
user/repo.git/git-receive-pack
can be matched with simple `^.user/repo.git/.(git-receive-pack)$. That will not work since 1st case in Nginx is not matched because location is user/repo.git/info/refs.