#!/bin/bash MBOX=/tmp/mbox PATCH_DIR=/tmp/patches PATCH_SERIES=/tmp/series sources=~/sources # Read patch series and import inside a git tree using guilt guilt_import() { for i in `tac $PATCH_SERIES`; do echo "Importing: $i" echo $PATCH_DIR/$i guilt import $PATCH_DIR/$i done } # Open a dialog with a list based on directories under $source directory, each # directory should be a git repository where the patches will be imported apply_patch() { repolist=$(ls $sources | awk '{print $1,$1}') tempfile=/tmp/item_menu.$$ dialog --clear --menu "Select repository to apply the patch" 0 0 20 $repolist 2> $tempfile #"Select repository to apply the patch" 30 60 20 $repolist 2> $tempfile repo=`cat $tempfile` cd $sources/$repo guilt init guilt_import rm -rf $tempfile } # Reads all files under a mailbox and its sub-directories (cur, new, tmp # usually), and transform all emails under there in patches to be applied to a # git tree mkdir $PATCH_DIR for dir in `ls $MBOX`; do for i in `ls $MBOX/$dir`; do FILE=$MBOX/$dir/$i SUBJ=`cat $FILE|formail -xSubject` TITLE=`echo $SUBJ| sed -e '{ s@\[@@g; s@\]@@g; s@[*()" \t]@_@g;s@[/:]@-@g; s@^ \+@@; s@\.\.@.@g; s@-_@_@g; s@__@_@g; s@\.$@@; }' | cut -c 1-70`.patch SUBJ=`echo $SUBJ | sed -e 's/\[[^]]*\]//'` PATCH=$PATCH_DIR/$TITLE echo $TITLE >> $PATCH_SERIES echo $SUBJ > $PATCH cat $FILE | formail -I "" >> $PATCH done done apply_patch rm -rf $PATCH_SERIES rm -rf $MBOX #clean patches rm -rf $PATCH_DIR