Tuesday, November 5, 2013

Applying Git patches in bulk from Claws Mail

As a Samba developer, I often spend a large amount of time reviewing and testing patches submitted to the samba-technical mailing list. This often sees me jumping between my mailer (Claws Mail) and the console, with the following procedure:
  • Retrieve mail
  • For each patch in the proposed series:
    • Save to local disk in rfc822 format
  • Switch to console
  • For each patch in the series:
    • Apply to the local branch using git am
  • Review and test

The process itself isn't overly time consuming, but given the frequency, I decided to set about automating it slightly using Claws Mail's Actions feature:

Configuration->Actions dialog
I added the above Action, which:
  • Enters my Samba source directory
  • Runs git am with arguments corresponding to all selected messages (%F)
With this simple one-liner, I can select a bunch of patch mails and apply them all to my local tree in one fell swoop.

Action IO dialog, triggered via Tools->Actions->samba_patch_git

I'm content with this approach, but readers should note that there are a number of pitfalls, namely:
  • Patch mails must be in a format that git am can parse. E.g. git send-email
  • The git repository needs to be in a state ready to accept the patches

No comments:

Post a Comment

Comments are moderated due to spammer abuse.