如何将 phabricator 获取到观察者本地 git 存储库

How to get phabricator to observer local git repository

我在 phabricator 中尝试观察本地 git 存储库时 运行 遇到错误。回购在同一台机器上 运行ning phabricator,我相信它拥有所有正确的权限,但 phab 无法识别路径。还有其他人 运行 遇到过类似的问题吗?你是怎么解决的?预先感谢您的指导。

主要错误:

phabricator-ssh-exec: Unrecognized repository path "/var/repos/git/test". Expected a path like "/diffusion/X/", "/diffusion/123/", or "/source/thaumaturgy".

我设置观察存储库的步骤:

Created a new repository in phabricator

Set the following (all) default URIs to "read only"
    ssh://git@phabricator.localhost.com:2222/diffusion/1/test Read Only Hidden
    ssh://git@phabricator.localhost.com:2222/source/test  Read Only Visible
    ssh://git@phabricator.localhost.com:2222/diffusion/TEST/test  Read Only Hidden

Created a 4th URI and set it to observe:
    ssh://git@phabricator.localhost.com:2222/var/repos/git/test Observe Hidden 

Set up credentials for that URI successfully

Activated respository

完整的 phabricator 错误:

Raw Error
Error updating working copy: Command failed with error #128!
COMMAND
git ls-remote '********'

STDOUT
( empty)

STDERR
Warning: Permanently added '[phabricator.localhost.com]:2222' (ECDSA) to the list of known hosts.
phabricator-ssh-exec: Unrecognized repository path "/var/repos/git/test". Expected a path like "/diffusion/X/", "/diffusion/123/", or "/source/thaumaturgy".
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

简短摘要:

我也尝试过使用 test.git。目录 /var/repos/git/test 存在并且是 wdev 组的 775(读、写、执行),其中 myuser 和 git 是成员

我不知道 phabricator 在哪里寻找这些目录。我期望从我的服务器的根目录,但 /diffusion/X 最确定的是不在我的服务器根目录。我做错了假设吗?

我尝试了其他 3 个 URI,但都因同样的错误而失败。我在下面提供了更多信息。

tl;dr

导致相同错误的其他步骤:

1.  Changed URI to ssh://git@phabricator.localhost.com:2222/var/repos/git/test.git
2.  Changed URI to ssh://git@phabricator.localhost.com:2222/home/myuser/local-repos/git/test.git
3.  Changed URI to ssh://git@phabricator.localhost.com:2222/home/myuser/local-repos/git/test

我的 phabricator SSH 用户:

[myuser@localhost ~]$ cat /etc/passwd |grep git
git:x:1002:1003::/var/repos/git:/bin/bash

[myuser@localhost ~]$ cat /etc/group |grep wdev
wdev:x:1001:myuser,apache,phd,git

[myuser@localhost ~]$ sudo cat /etc/shadow |grep git
git:NP:17669:0:99999:7:::

[myuser@localhost ~]$ sudo cat /etc/sudoers.d/phabricator-sudoers
git All=(phd) SETENV: NOPASSWD: /usr/bin/ls, /usr/bin/git, /usr/bin/git-upload-pack, /usr/bin/git-receive-pack, /usr/bin/ssh
apache All=(phd) SETENV: NOPASSWD: /usr/bin/git, /usr/bin/git-http-backend
myuser All=(phd) SETENV: NOPASSWD: /var/www/phabricator/phabricator/bin/phd

Phabricator SSH 用户可以 ssh:

[myuser@localhost ~]$ echo {} | ssh -p 2222  git@phabricator.localhost.com conduit conduit.ping
{"result":"localhost.localdomain","error_code":null,"error_info":null}

测试存储库路径的权限

[myuser@localhost apache2-php7-postgres]$ cd /var

[myuser@localhost var]$ ls -ltrh |grep repos
drwxrwxr-x.  3 myuser wdev   4.0K May  2 16:21 repos

[myuser@localhost var]$ cd repos

[myuser@localhost repos]$ ls -ltrh |grep git
drwxrwxr-x. 4 myuser wdev 4.0K May 18 08:00 git

[myuser@localhost repos]$ cd git

[myuser@localhost git]$ ls -ltrh
total 4.0K
drwxrwxr-x. 7 myuser wdev 4.0K May  2 16:47 test

[myuser@localhost git]$ cd test

[myuser@localhost test]$ ls -alrh
total 40K
drwxrwxr-x. 4 myuser wdev 4.0K May  2 16:47 refs
drwxrwxr-x. 7 myuser wdev 4.0K May  2 16:47 objects
drwxrwxr-x. 2 myuser wdev 4.0K May  2 16:47 info
drwxrwxr-x. 2 myuser wdev 4.0K May  2 16:47 hooks
-rw-rw-r--. 1 myuser wdev   23 May  2 16:47 HEAD
-rw-rw-r--. 1 myuser wdev   73 May  2 16:47 description
-rw-rw-r--. 1 myuser wdev   66 May  2 16:47 config
drwxrwxr-x. 2 myuser wdev 4.0K May  2 16:47 branches
drwxrwxr-x. 4 myuser wdev 4.0K May 18 08:00 ..
drwxrwxr-x. 7 myuser wdev 4.0K May  2 16:47 .

[myuser@localhost test]$ pwd
/var/repos/git/test

然后我通过 运行ning

克隆了测试库
cd /home/myuser/local-repos/git/
git clone /var/repos/git/test

我将 URI 更改为使用 /home/myuser/local-repos/git/test

克隆的目录权限和内容

[myuser@localhost home]$ ls -ltrh |grep myuser
drwx------. 25 myuser myuser 4.0K May 18 08:10 myuser

[myuser@localhost home]$ cd myuser/

[myuser@localhost ~]$ ls -ltrh |grep local-repos
drwxrwxr-x. 3 myuser wdev     4.0K May  2 16:13 local-repos

[myuser@localhost ~]$ cd local-repos/

[myuser@localhost local-repos]$ ls -altrh
total 12K
drwxrwxr-x.  3 myuser wdev     4.0K May  2 16:13 .
drwxrwxr-x.  3 myuser wdev     4.0K May 18 08:00 git
drwx------. 25 myuser myuser 4.0K May 18 08:10 ..

[myuser@localhost local-repos]$ cd git

[myuser@localhost git]$ ls -altrh
total 12K
drwxrwxr-x. 3 myuser wdev 4.0K May  2 16:13 ..
drwxrwxr-x. 3 myuser wdev 4.0K May  2 16:47 test
drwxrwxr-x. 3 myuser wdev 4.0K May 18 08:00 .

[myuser@localhost git]$ cd test

[myuser@localhost test]$ ls -altrh
total 16K
-rw-rw-r--. 1 myuser wdev    3 May  2 16:47 init.txt
drwxrwxr-x. 3 myuser wdev 4.0K May  2 16:47 .
drwxrwxr-x. 8 myuser wdev 4.0K May  2 16:47 .git
drwxrwxr-x. 3 myuser wdev 4.0K May 18 08:00 ..

尝试删除第 4 个 URL(您的),并将 ssh://git@phabricator.localhost.com:2222/source/test 更改为 Observe 模式。该错误是由于 URL 不应指向目录(在文件系统中)本身,而应指向 Phabricator 创建的指向它的 URL(s)。

它适用于我的设置。

我正在为这个新的 ssh URI 使用我的 phabricator ssh 用户 (git),结果发现该用户无法观察本地文件系统上已经存在的 repo。我将 URI 更改为在端口 22 上使用常规 ssh(不是 phabricator 的 ssh,它是端口 2222 上的运行)并以我的用户身份 ssh:

ssh://myuser@phabricator.localhost.com/var/repos/git/test Observe Hidden 

所以现在我为这个预先存在的本地存储库配置了以下 URI:

ssh://myuser@phabricator.localhost.com/var/repos/git/test Observe Hidden 
ssh://git@phabricator.localhost.com:2222/diffusion/1/test Read Only Hidden
ssh://git@phabricator.localhost.com:2222/source/test  Read Only Visible
ssh://git@phabricator.localhost.com:2222/diffusion/TEST/test  Read Only Hidden

而且 Phab 正在观察我的存储库!

我不知道这是否标准,但对我来说,就我现在的目的而言,这是可行的。如果有人有其他建议或想法,我很乐意听取。