5

我正在尝试使用 Phabricator 的代码审查功能对班级学生提交的代码进行评分。代码提交到 Subversion 服务器,其中每个学生在服务器的顶级位置下都有自己的文件夹。对于当前的课程,我无法控制根位置。如果我这样做了,我只会移动它,以便有一个文件夹,其中包含我需要的课程的所有学生存储库,并在该文件夹中创建一个存储库并与较低的分支进行比较,但此时我不能。

我找到了一种方法,可以从命令行在 Phabricator 中完成几乎所有我需要做的事情,例如创建每个学生用户并生成差异。只有一件事我不知道该怎么做:创建一个存储库。

我查看了 Phabricator 和 Arcanist 帮助中的选项,但我没有看到任何似乎可以满足我需要的东西。

有谁知道是否可以从 Phabricator 或 arc 命令行创建存储库?或者以其他一些自动化的方式?

谢谢!

4

3 回答 3

7

我们目前还没有真正简单的方法来执行此操作,但您可以使用它arc来调用 Conduit API。将 JSON blob 通过管道传输到其中:

echo '{"name":"repo name", ...}' | arc call-conduit repository.create

您可以/conduit/method/repository.create/在 Web UI 上访问调用接受的参数列表。

于 2014-01-12T18:14:09.413 回答
1

更新 Evan Priestley 的回答:API 方法已更改为diffusion.repository.edit.

开发人员文档在此处解释了如何创建和激活存储库。从该文件复制:

创建一个仓库:

$ echo '{
  "transactions": [
    {
      "type": "vcs",
      "value": "git"
    },
    {
      "type": "name",
      "value": "Poetry"
    }
  ]
}' | arc call-conduit diffusion.repository.edit

使用来自第一个响应的事务 ID 设置远程 URL(如果需要):

$ echo '{
  "transactions": [
    {
      "type": "repository",
      "value": "PHID-REPO-7vm42oayez2rxcmpwhuv"
    },
    {
      "type": "uri",
      "value": "https://github.com/epriestley/poems.git"
    },
    {
      "type": "io",
      "value": "observe"
    }
  ]
}' | arc call-conduit diffusion.uri.edit

激活回购:

$ echo '{
  "objectIdentifier": "PHID-REPO-7vm42oayez2rxcmpwhuv",
  "transactions": [
    {
      "type": "status",
      "value": "active"
    }
  ]
}' | arc call-conduit diffusion.repository.edit

所有有效参数的列表可在 Web UI 中找到/conduit/method/diffusion.repository.edit/

于 2016-11-21T14:49:18.850 回答
1

因为我有带有 VCS 服务器 (HG) 的 VM1 和带有 Phabricator 的另一个 VM2,所以我制作了简单的脚本,从 VCS 中的命令行 repo 制作并在 Phab 中创建链接 repo。这是脚本的核心:

#!/bin/bash
REPO=$1
new_URI="http://vcs.domain.com/"$1

create_phab_repo() {
curl http://phabricator.domain.com/api/diffusion.repository.edit \
    -d api.token=api-blablablabla \
    -d transactions[0][type]=vcs \
    -d transactions[0][value]=hg \
    -d transactions[1][type]=name \
    -d transactions[1][value]=$REPO
}


add_phab_repo_URI() {
curl http://phabricator.domain.com/api/diffusion.uri.edit \
    -d api.token=api-blablablabla \
    -d transactions[0][type]=repository \
    -d transactions[0][value]=$2 \
    -d transactions[1][type]=uri \
    -d transactions[1][value]=$new_URI \
    -d transactions[2][type]=io \
    -d transactions[2][value]=observe
}


activate_phab_repo() {
curl http://phabricator.domain.com/api/diffusion.repository.edit \
        -d api.token=api-blablablabla \
        -d transactions[0][type]=status \
        -d transactions[0][value]=active \
        -d objectIdentifier=$1
}

…………

content=$( create_phab_repo | jq -r '.result.object.phid' )

repo_phid=$( curl http://phabricator.domain.com/api/diffusion.repository.edit -d api.token=api-blablablabla -d transactions[0][type]=vcs -d transactions[0][value]=hg -d transactions[1][$REPO | jq -r '.result.object.phid')

add_phab_repo_URI $1 ${repo_phid}

activate_phab_repo ${repo_phid}

希望这对某人有帮助

于 2020-02-21T11:20:02.767 回答