【问题标题】:Providing HTTP read-only access to svn checkout on a PHP server?在 PHP 服务器上提供对 svn checkout 的 HTTP 只读访问权限?
【发布时间】:2014-11-30 04:24:14
【问题描述】:

我在服务器上有一些 Subversion 存储库(最初使用 svnadmin 创建);通过svn+ssh:// 有经过身份验证的SSH 读写访问。对于某些 SVN 存储库,我想通过http:// 允许匿名只读访问。问题是我在该服务器上没有管理属性,所以我不能真正搞乱服务器设置或运行svnserve,但我可以拥有 PHP 脚本。所以我想知道是否有一些解决方案,希望在 PHP 中,可以让我这样做(实现一个到 subversion 存储库的“桥”,svn 客户端可以从中签出)?

我想比较一下我想用git 做什么。如果我在目录中执行git init,我会得到子文件夹.git,其中包含与裸回购完全相同的内容。我可以使用 git clone --bare ... 克隆这个裸仓库,然后将其上传到服务器 - 然后我可以使用 git clone http://... 和裸仓库的位置直接克隆(除了一开始,git 会抱怨 @ 987654337@; 这意味着我应该 enable the default post-update hook [which] runs git update-server-info to keep the information used by dumb transports (e.g., HTTP) up-to-date.; 或在裸仓库中运行 git update-server-info,因此生成 info/refs - 只有这样才能通过 HTTP 将服务器上的这个裸仓库克隆到客户端上)。

所以,我认为 svnadmin 创建的仓库(内容为 dav db format hooks locks README.txt)等同于 git 裸仓库(因为它们都包含整个历史记录,没有实际文件),所以我希望svnadmin repo 可以以相同的方式设置为只读 HTTP 克隆(即,只需在服务器上复制该文件夹内容)。不幸的是,事实并非如此——似乎即使使用 HTTP 访问,svn 实际上也与服务器上的一种 WebDAV 形式进行通信(Subversion Users: Re: dav directory does not existSVN RedBook: What is WebDAV?)。所以我尝试了sabre/dav,但是在成功的简单设置之后(使用cadaver DAV 命令行工具测试),如果我指向svnadmin repo 目录(或其dav/ 子目录),我只能得到svn: OPTIONS of 'http://...': 200 OK (http://...) .

我想我想要的可能在当时是不可能的:

Re: SVN or git via WebDav using SabreDAV - Google Groups

SVN 协议需要对普通 webdav 进行大量扩展才能工作。你在这里基本上不走运。

...但我想用这个问题确认一下...


感谢@Evert 的回答;但不幸的是svnsync 在这里似乎对我没有帮助(它因“存储库永久移动”而失败);这是我在 Apache 服务器目录上的 bash 中运行的一组命令,其中一些命令响应以 # 为前缀:

svn --version
# svn, version 1.6.6 (r40053)

cd /media/www
svnadmin create mytest.svnfs
svn co file:///media/www/mytest.svnfs mytest.svn

cd mytest.svn
echo aaa >> test.txt
svn add test.txt
svn commit -m "init commit"
echo bbb >> test.txt
svn add test.txt
svn commit -m "2nd com  mit"
wget -q --no-check-certificate http://localhost/mytest.svn -O - | head --bytes 120
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
# <html>
#  <head>
#   <title>Index of /mytest.svn</title>

cd ..
svnadmin create mytest.mirror
cat > mytest.mirror/hooks/pre-revprop-change <<'EOF'
#!/bin/sh
USER="$3"

if [ "$USER" = "syncuser" ]; then exit 0; fi

echo "Only the syncuser user can change revprops" >&2
exit 1
EOF
chmod +x mytest.mirror/hooks/pre-revprop-change
cat > mytest.mirror/hooks/start-commit <<'EOF'
#!/bin/sh

USER="$2"

if [ "$USER" = "syncuser" ]; then exit 0; fi

echo "Only the syncuser user may commit new revisions" >&2
exit 1
EOF
chmod +x mytest.mirror/hooks/start-commit
ls --ignore="*.tmpl" mytest.mirror/hooks/
# pre-revprop-change  start-commit

svnsync initialize file:///media/www/mytest.mirror http://localhost/mytest.svnfs/ --sync-username syncuser --sync-password syncpass
# svnsync: Repository moved permanently to 'http://localhost/mytest.svnfs/'; please relocate

# trying the working copy (even if it shouldn't work):
svnsync initialize file:///media/www/mytest.mirror http://localhost/mytest.svn/ --sync-username syncuser --sync-password syncpass
# svnsync: Repository moved permanently to 'http://localhost/mytest.svn/'; please relocate

【问题讨论】:

    标签: php svn webdav


    【解决方案1】:

    我写了那个答案,它仍然成立。

    简而言之:

    1. SVN 服务器可以使用 webdav、Delta-V(webdav 的版本控制扩展)
    2. SVN 客户端利用该服务器,但也需要 svn 扩展。

    几年前确实如此,所以情况可能已经改变......但我真诚地怀疑它。

    但是..对于您想做的事情,听起来您只想使用svnsync

    http://svnbook.red-bean.com/en/1.7/svn.reposadmin.maint.html#svn.reposadmin.maint.tk.svnsync

    【讨论】:

    • 非常感谢您的确认,@Evert;也感谢svnsync 指针 - 我尝试了现在在 OP 编辑​​中的测试,但不幸的是它失败了,“存储库永久移动”(与指定的完全相同的 URL)。再次感谢 - 干杯!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-18
    • 1970-01-01
    • 1970-01-01
    • 2021-07-05
    • 2019-05-11
    • 1970-01-01
    相关资源
    最近更新 更多