lundi 7 janvier 2019

Gerrit mail header X-Gerrit-MessageType

Values for the field X-Gerrit-MessageType based on my email inbox and Gerrit source code (gerrit-server/src/main/java/com/google/gerrit/server/mail/send/* classes):
  • abandon
  • addkey
  • comment
  • deleteReviewer
  • deleteVote
  • merged
  • newchange
  • newpatchset
  • registernewemail
  • restore
  • revert
  • setassignee

jeudi 30 novembre 2017

Watching an Xvfb frame buffer

Start Xvfb with a memory mapped file:

/usr/bin/Xvfb :94 -screen 0 1280x1024x24 -fbdir "$HOME"

Watch it:

xwud -in Xvfb_screen0

Profit.

vendredi 13 juin 2014

Editor war haiku

all code editors
albeit so much nicer
can act such as vi

mercredi 25 septembre 2013

displaying Gerrit review history in git log

Over the last few weeks, several people complained I should share my tip'n tricks with more people. They are apparently worth a post.  I am giving it a try there to show you how to make available in your git cli the Gerrit review informations. I will start with some context then spurt magical commands to let you make it happen on your own computer.

In the beginning of 2012, the Wikimedia Foundation switched from Subversion to Git. The main reason for the switch was to prevent committers from inserting bad code in the central repository. Thus lowering the stress when deploying said code on the production site.  The only way to do it is to elect a gatekeeper between patch authors and the reference repository used for deployment. In Linux, that is more or less the role of Linus Torvalds. At Wikimedia we selected Gerrit which is used at Google to accept patches for their Android platform.

The Gerrit workflow is pretty simple: authors send their patches to Gerrit, he and others comment or amend the patch, rinse and repeat until there is no more to say. After a few iterations, the community ends up with a robust patch which is worth entering the reference repository. A few people are allowed to approve the change and have it actually merged.

The history that led to the final commit is available (example for a patch I wrote: https://gerrit.wikimedia.org/r/75569) and is very valuable whenever a bug appear: the comments can give you an idea of the design choices and list out every single person that get involved in the patch. If the original author is not available, you can most probably reach out to the person that review the code. When you are facing an issue in production, the more people to ask the merrier.

It is too cumbersome to have to open the browser in the Gerrit web interface. Aging, I rely more and more on terminals and command lines. How would I get the commit history from the command line without having to parse some Gerrit json? Luckily, there is a way to get all the reviewing history saved locally and thus available offline.

Internally, Gerrit relies a lot upon git, its internal configuration for a given repository is even available (under refs/meta/config). The review history for a repository is thus stored in Git as well and it lives under refs/notes.

You can thus fetch all the review history:
git fetch -v origin refs/notes/*:refs/notes/*
Then configure your repository to always show the notes in git log:
git config --local notes.displayRef refs/notes/review
End result:

$ git log -n1 1dad0218
commit 1dad021840bf936b0e130ddda3459d11f0ad8421
Author: Antoine Musso 
Date:   Wed Jul 24 12:08:52 2013 +0200

    SpecialPrefixindex formatting methods are now protected
    
    namespacePrefixForm() and showPrefixChunk() accepted additional
    arguments to slightly alter the form such as hiding redirects.  The
    argument has been removed in favor of class property just like
    stripprefix introduced earlier and the method have been made protected
    since there is no point in calling them out of the special page scope.
    
    Change-Id: I55728fd2634f8a935a033052dcce3c7247cb1aa3

Notes (review):
    Verified+2: jenkins-bot
    Code-Review+2: Matmarex 
    Submitted-by: jenkins-bot
    Submitted-at: Fri, 30 Aug 2013 19:41:21 +0000
    Reviewed-on: https://gerrit.wikimedia.org/r/75569
    Project: mediawiki/core
    Branch: refs/heads/master


On this patchset, we can see that Matmarex has accepted the change :-) You can prevent notes from displaying whenever you like by passing --no-notes to the git log command. Note: you will have to fetch the notes from time to time since they are not fetched by default. An alias would be useful:
git config --global alias.fetchreviews \ 'fetch -v gerrit refs/notes/review:refs/notes/review'
You can then refresh notes by nvoking git fetchreviews.

Summary:

* Get notes: git fetch -v origin refs/notes/review:refs/notes/review
* Configure git to always show them: git config --local notes.displayRef refs/notes/review

mercredi 7 mars 2012

si la france était un ménage

Et oui, si l'état Français était un ménage. Que pourrait on voir ? En gros le résumé c'est: y a plus de sous :-)

Fillon l'avais d'ailleurs très bien résumé lors de son premier déplacement officiel en Corse en tant que premier ministre. On pourra revoir ce rare moment de franchise sur le site de l'INA, je cite:

« je suis à la tête d'un état qui est en situation de faillite sur le plan financier.
Je suis à la tête d'un état qui est, depuis quinze ans en déficit chronique.
Je suis à la tête d'un état qui n'a jamais voté un budget en équilibre depuis vingt-cinq ans.
Bon. Ca peut pas durer.  »






Bref.


En gros, si la France était un ménage gagnant 19 782 euros net par an, elle dépenserait 28 640 euros par an. Allez pour que ça rentre bien j'en remet une couche:


  • Revenus : 19 782 euros
  • Dépenses : 28 640 euros

N'importe qui de censé, prendrais des mesures drastiques pour réduire ses dépenses. Même si, au niveau d'un état, ce n'est pas aussi simple à résumer. Un état va par exemple emprunter pour investir dans le futur, ces investissements permettront d'engendrer de l'activité donc des recettes avec l'impôt.

Toujours est il que notre ménage se retrouve avec un trou de 738 euros dans le budget chaque fin de mois. Avec, je le rappelle, un budget de 1648€ par mois. Ce ménage devrait donc emprunter près de 9000 euros par an, qui devrait bien sûr s'ajouter aux dettes déjà accumulées de 180 000 euros.

Et bien heureusement, ce ménage dispose d'un agent en charge d'emprunter pour lui. C'est l'Agence France Trésor pour l'état:


01 Mars 2012Émission de l'AFT : 7,991 milliards d'OAT


Et voilà. C'est l'équivalent de 799 euros pour notre ménage.


Bien sur ce ménage n'a pratiquement pas d'augmentation de ressources (la croissance) à envisager pour l'avenir.

On dira ce qu'on voudra. Quand y a plus de sous y a plus de sous. Et quelque soit le résultat de la présidentielle de 2012, ça veut dire moins de service public et plus d'impôts pour les prochaines années.