Creating drafts and changes for VPP

This really is just a tiny notebook to dump something I had sitting in the notebook and reused every now and then, and add a bit of prose around it. It is all really documented in various other places, I just add it here for the convenience of copypasting.

When you want to make a change to VPP that can be considered for a commit, it needs to pass the review and the CI run via gerrit change. In order to do that, the repository needs to be specially prepared.

You clone the code as usual.

git clone https://gerrit.fd.io/r/vpp

But before you commit anything, there needs to be a script that generates the change-id as part of the commit message. So, in order not to forget to do it later, just do it right away in the newly cloned git repo.

curl -Lo .git/hooks/commit-msg https://gerrit.fd.io/r/tools/hooks/commit-msg
chmod +x .git/hooks/commit-msg
Now create the temporary local branch where you will do the change:
git checkout -b my-cool-change

We are mostly done. Now time to draw the rest of the owl... Or, rather, code and commit, via "git commit -a -s" (the latter flag is needed to get the sign-off into the commit message). You will notice that the resulting commit message has a long hex number containing the change-id. This will be used to uniquely identify the change, since you might need multiple iterations before the code is ready for the merge to the VPP.

When you are ready to push the change:

git push origin HEAD:refs/for/master

This will trigger the CI build and as well the change will be visible to anyone browsing the Gerrit changes.

If you want to update the code, you can edit it in this local temporary branch, then amend the local commit:

git commit -a --amend

Then you can push again and the change will be updated with the most current version.