Emmanuel Vadot's Journal


FreeBSD, Electronics and more


How to contribute to FreeBSD with phabricator and git

FreeBSD uses svn as it's main SCM but also offers a git mirror at github.

FreeBSD also have two website for submitting code, bugzilla and phabricator. The first is for bugs (duh) and the second is for new code (new platform, hardware, framework etc ...).

On this post I'll present how I work with git and arcanist (the phabricator cli tool). Please note that this is my way of doing things as an external contributor to the project and it's clearly not the only way.

The first things that you'll need is a fork repo of freebsd on your github account. To do that siply go on the FreeBSD project github page and click the fork button.

Now clone this fork locally and add the official github mirror as a new remote :

git clone git@github.com:${username}/freebsd.git
cd freebsd.git
git remote add upstream https://github.com/freebsd/freebsd.git

I leave the master branch of my repo untouched and I occasionnaly sync it with upstream :

git checout master
git fetch upstream
git merge upstream/master
git push

The git push is important because arcanist will create a diff based on what haven't been pushed.

Now when I want to work on a feature (either a bug or a new feature), I create a new branch based on master and work in it :

git checkout -b my_new_feature
# Write code
git add newfile.c
git commit
git push

So now you have some cool new feature that you want to submit, go on the phabricator website and create a account. For external contributor the account name will be based on your email, if your email is bob@example.com your username will be bob_example.com.

Install arcanist on your machine and create a cli token :

pkg install php5-arcanist
arc install-certificate

This will prompt you an url to visit with the token to paste on the cli tool.

After that edit the file ~/.arcrc to have something like that :

{
  "hosts": {
    "https://reviews.freebsd.org/api/": {
      "token": "cli-myarctoken"
    }
  },
  "config": {
    "base": "git:merge-base(origin/master), arc:prompt"
  }
}

The "base" variable in the config section will tell arc how to generate a proper diff (this will be the same as git diff master.

And you just need to run arc diff to create a new diff on phabricator.

After the diff is created just visit the url that arc printed and either create a new revision or update one of yours.