Phabricator - 存储库的文件夹结构

时间:2015-12-15 17:31:06

标签: repository gitolite phabricator

我有300个本地存储库使用gitolite管理。版本控制服务器上的存储库的文件夹结构如下所示:

folder1/folder2/repo1.git
folder1/folder2/repo2.git
folder1/folder3/repo3.git
folder1/repo4.git

如果存储库名称是:folder1 / folder2 / repo5.git,则存储库将进入folder1 / folder2 /,依此类推。

在Phabricator中,您有一个包含所有存储库的文件夹。

如何将Phabricator中的存储库构建在更多文件夹中?

2 个答案:

答案 0 :(得分:1)

http://phab.example.com/diffusion/CALLSIGN/edit/storage/上,您可以看到存储位置可以通过命令行ala

进行更改
phabricator/ $ ./bin/repository edit CALLSIGN --as user --local-path ...

答案 1 :(得分:1)

我还有一个文件夹结构,我在其中管理子文件夹中的存储库类别。由于我们创建的几个脚本仍然需要这个文件夹结构,我们编写了一个额外的bash脚本...这个脚本遍历所有文件夹。对于每个git存储库,生成呼号,并将管道调用发送到phabricator以创建关于扩散回购。 如果我们创建新的repos,我们首先创建git存储库本身,然后我们的附加脚本创建扩散存储库。 如果你有兴趣,我也可以发布该脚本。

脚本来了:

#!/bin/bash

dryrun="false"
overwrite="false"


if [ $# = 1 ]; then
  if [ $1 = "dryrun" ]; then
    dryrun="true"
  fi
  if [ $1 = "overwrite" ]; then
    overwrite="true"
  fi
fi

folders_cat_a=(/var/git/folder1 /var/git/folder2 /var/git)
folders_cat_b=(/var/git/folder3 /var/git/folder4 /var/git/folder5)

CALLSIGNS=()

# PHIDs:
# Project A+B
phidAB="PHID-PLCY-wbdhp4lpqhm4so7qafaj"
# Project A
phidA="PHID-PROJ-vcfjz6kvjqqec2szdgno"
# Project B
phidB="PHID-PROJ-jjezy3xb6cbbwdshoihm"

# little method to check whether or not an array contains a dedicated element
containsElement () {
  local e
  for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
  return 1
}

createPhabricatorRepo () {

  # for all *.git sub folders in the passed folder
  for i in $( ls $1 | grep '\.git$'); do

    # build the repository name and callsign from the folder name
    name=$(sed 's|.git||g' <<< $i)

    # remove '-'
    callsign=$(sed 's|-||g' <<< $i)
    # remove '_'
    callsign=$(sed 's|_||g' <<< $callsign)
    # replace 'vXXX'
    callsign=$(sed 's|v000||g' <<< $callsign)
    callsign=$(sed 's|v100|ONE|g' <<< $callsign)
    callsign=$(sed 's|v200|TWO|g' <<< $callsign)
    # remove '.git'
    callsign=$(sed 's|.git||g' <<< $callsign)
    #replace any remaining numbers
    callsign=$(sed 's|[0-9]|X|g' <<< $callsign)
    # to uppercase
    callsign=${callsign^^}

    # test whether callsign already exists, append an additional letter if it exists
    if containsElement "$callsign" "${CALLSIGNS[@]}"; then
      for j in {B..Z};
      do
        if ! containsElement "$callsign$j" "${CALLSIGNS[@]}"; then
          callsign=$callsign$j
          break
        fi
      done
    fi

    # add callsign to array
    CALLSIGNS+=($callsign)

    if [ $dryrun = "false" ]; then

      if [ $overwrite = "true" ]; then
        /var/phabricator/scripts/destroy-by-monogram.sh r$callsign
      fi

      echo '{
      "name":"'$name'",
      "clone-name":"'$name'",
      "callsign":"'$callsign'",
      "vcs":"git",
      "encoding":"UTF-8",
      "hosting-enabled":true,
      "serve-over-http":"off",
      "serve-over-ssh":"readwrite",
      "viewPolicy":"'$phidAB'",
      "editPolicy":"admin",
      "pushPolicy":"'$2'",
      "allow-dangerous-changes":true,
      "localPath":"'$1'/'$i'"}' | arc call-conduit repository.create | grep -v "ERR-DUPLICATE"

    else

      echo $1/$i
      echo "name: "$name
      echo "callsign: "$callsign
      echo ""

    fi

  done

}

for folder in ${folders_cat_a[@]}; do
  createPhabricatorRepo $folder $phidA
done

for folder in ${folders_cat_b[@]}; do
  createPhabricatorRepo $folder $phidB
done

请注意,我扩展了phabricators conduit api,以便能够传递策略,允许危险更改和克隆名称。