在 OS X 中通过 HTTP 进行 Git 后接收

发布于 2024-12-19 16:43:47 字数 3519 浏览 4 评论 0原文

我的设置是:
1. OS X 运行 apache 服务器用于 Git 存储。
2. 我的 Git 项目目录位于:/Library/WebServer/Documents/CI
3.我已经按照本教程进行操作: http://www.pkgbox.org/wordpress/2011/08/setting-up-a-git-server-on-macos-x-lion/ 并设置 Git通过 HTTP 访问
4. 我的 gitrepo.conf 就像:

DavLockDB "/var/www/DavLock/Lock"
DavMinTimeout 28800

<Directory /Library/WebServer/Documents/CI>
  DAV On
  Deny from all
  AuthType Basic
  AuthName "Area51 git repositories"
  AuthUserFile /etc/apache2/other/htpasswd-git
  AuthGroupFile /etc/apache2/other/htgroup-git

</Directory>
<Directory /Library/WebServer/Documents/CI/ci_test.git>
Allow from all 
Order allow,deny
Require valid-user
<Limit GET>
Require group myproject-reader
</Limit>
<Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Require group myproject-writer
</Limit>
</Directory>

5. 通过 HTTP 的身份验证正在工作,我有不同的用户和不同的组,一切都工作正常。

我的问题是: 我希望能够在我的 git 中使用 post-receive hook。我读过这个问题: Git post-receive hook 不起作用 我从那里得到的是我需要设置 SMART HTTP。不幸的是这个链接: http://www.kernel.org/ pub/software/scm/git/docs/git-http-backend.html 得到我 404。

我在这里读到:http://progit.org/2010/03/04/smart-http.html< /a> 但我在设置服务器方面确实是新手,我不明白我应该做什么...你能为我提供激活 GIT 挂钩的有效配置吗?

建议的解决方案 更改为智能 HTTP。

这是我当前的 gitrepo.conf

<VirtualHost *:80>
  ServerName ciserver.smt
  DocumentRoot /Library/WebServer/Documents/CI

  SetEnv GIT_PROJECT_ROOT /Library/WebServer/Documents/CI
  SetEnv GIT_HTTP_EXPORT_ALL

  ScriptAlias / /usr/libexec/git-core/git-http-backend/
  AliasMatch ^/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /Library/WebServer/Documents/CI/$1
  AliasMatch ^/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /Library/WebServer/Documents/CI/$1

  ScriptAliasMatch \
    "(?x)^/(.*/(HEAD | \
    info/refs | \
    objects/(info/[^/]+ | \
        [0-9a-f]{2}/[0-9a-f]{38} | \
        pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
    git-(upload|receive)-pack))$" \
    /usr/libexec/git-core/git-http-backend/$1

  <LocationMatch "^/.*/git-receive-pack$">
    AuthType Basic
    AuthName "Git"
    AuthUserFile /etc/apache2/other/htpasswd-git
    AuthGroupFile /etc/apache2/other/htgroup-git
   <Limit GET>
    Require group myproject-reader
   </Limit>
   <Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
    Require group myproject-writer
   </Limit>
     </LocationMatch>
</VirtualHost>

我已更改 /etc/hosts 以添加 ciserver.smt 指向 127.0.0.1 现在我无法提出这个请求:

git clone http://[email protected]/ci_test.git

我得到:

error: The requested URL returned error: 403 while accessing http://[email protected]/ci_test.git/info/refs

fatal: HTTP request failed

我还做错了什么?

My setup is:
1. OS X runnig apache server for Git storage.
2. My directory for Git projects is here: /Library/WebServer/Documents/CI
3. I've followed this tutorial: http://www.pkgbox.org/wordpress/2011/08/setting-up-a-git-server-on-macos-x-lion/ and setted up Git access over HTTP
4. My gitrepo.conf is like:

DavLockDB "/var/www/DavLock/Lock"
DavMinTimeout 28800

<Directory /Library/WebServer/Documents/CI>
  DAV On
  Deny from all
  AuthType Basic
  AuthName "Area51 git repositories"
  AuthUserFile /etc/apache2/other/htpasswd-git
  AuthGroupFile /etc/apache2/other/htgroup-git

</Directory>
<Directory /Library/WebServer/Documents/CI/ci_test.git>
Allow from all 
Order allow,deny
Require valid-user
<Limit GET>
Require group myproject-reader
</Limit>
<Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
Require group myproject-writer
</Limit>
</Directory>

5. Authentication over HTTP is working, I've got different users and different groups and it is all working fine.

My problem is:
I want to be able to use post-receive hook in my git. I've read this question: Git post-receive hook not working
And what I'm getting from there is that I need to setup SMART HTTP. Unfortunatly this link:
http://www.kernel.org/pub/software/scm/git/docs/git-http-backend.html get's me 404.

I've read here: http://progit.org/2010/03/04/smart-http.html but I'm really newbie in setting up servers and I don't understand what I am suppose to do... Could you provide me with valid configuration for activating GIT hooks?

Proposed solution
Changing to SMART HTTP.

Here is my current gitrepo.conf

<VirtualHost *:80>
  ServerName ciserver.smt
  DocumentRoot /Library/WebServer/Documents/CI

  SetEnv GIT_PROJECT_ROOT /Library/WebServer/Documents/CI
  SetEnv GIT_HTTP_EXPORT_ALL

  ScriptAlias / /usr/libexec/git-core/git-http-backend/
  AliasMatch ^/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$          /Library/WebServer/Documents/CI/$1
  AliasMatch ^/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /Library/WebServer/Documents/CI/$1

  ScriptAliasMatch \
    "(?x)^/(.*/(HEAD | \
    info/refs | \
    objects/(info/[^/]+ | \
        [0-9a-f]{2}/[0-9a-f]{38} | \
        pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
    git-(upload|receive)-pack))$" \
    /usr/libexec/git-core/git-http-backend/$1

  <LocationMatch "^/.*/git-receive-pack$">
    AuthType Basic
    AuthName "Git"
    AuthUserFile /etc/apache2/other/htpasswd-git
    AuthGroupFile /etc/apache2/other/htgroup-git
   <Limit GET>
    Require group myproject-reader
   </Limit>
   <Limit GET PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
    Require group myproject-writer
   </Limit>
     </LocationMatch>
</VirtualHost>

I've changed /etc/hosts to add ciserver.smt as pointing into 127.0.0.1
Now I'm unable to make this request:

git clone http://[email protected]/ci_test.git

I'm getting:

error: The requested URL returned error: 403 while accessing http://[email protected]/ci_test.git/info/refs

fatal: HTTP request failed

What did I still do wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静若繁花 2024-12-26 16:43:47

看来您无法在 webdav 共享存储库上运行挂钩。但是您可以使用智能 HTTP 协议(​​通过 CGI 包含在 Web 服务器中),它可以处理钩子。

请参阅 http://dev。 bazingaweb.fr/2011/02/23/how-to-set-up-git-over-http.html 了解更多详细信息。

It seems that you can't run hooks on a webdav shared repo. But you can use the smart HTTP protocol (which is included into the web server via CGI), which does handle hooks.

See http://dev.bazingaweb.fr/2011/02/23/how-to-set-up-git-over-http.html for more details.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文