Search code examples
gitrepositoryphabricator

How to integrate a local git repository in Phabricator Diffusion?


System setup: phabricator installed as well as git set up (not part of this question) on same machine

git repositories under /srv/git e.g. /srv/git/my/example.git

user accounts:

  • "git" with group "git" (for git)
  • "bugs" with groups "bugs git" (for phabricator)

This is just an example, please adopt to your specific setup and needs!

Now, how to get this locally hosted git repository into Phabricator Diffusion (as external repository) without making phabricator the main authority?


Solution

  • One way will be to use ssh with a public key to access the local repository:

    1. create public and private key (aka credentials) in Phabricator:

      Applications -> Passphrase -> "Create Credential" -> "SSH Private Key (Generated)"

      NOTE: You may want to lock the credential generated to prevent leakage of private key!

    2. if not present, create .ssh folder and authorized_keys file for phabricator user 'bugs'

      mkdir .ssh

      touch .ssh/authorized_keys

    3. check permissions 600 of authorized_keys and 700 of .ssh

      chmod 700 .ssh

      chmod 600 .ssh/authorized_keys

    4. copy public key of phabricator user ('bugs') into .ssh/authorized_keys

      NOTE: Phabricator user must have read access to git folders (should have by being in group 'git')

    5. create diffusion repository (external hosting) e.g. "ssh://bugs@localhost/srv/git/my/example.git"

      Phabricator -> Diffusion -> New Repository -> "Import an Existing External Repository" -> follow instructions ...

    You may want to activate the repository after checking it first. When active, import should start automatically and you can now use it, e.g. create notifications (Herald) when changes are recognized etc.

    NOTE: The repository will stay hosted under /srv/git as main authoritive master!