summaryrefslogtreecommitdiff
path: root/stale/make_patchlist.sh
diff options
context:
space:
mode:
authorCarlos Maiolino <[email protected]>2024-04-21 13:52:26 +0200
committerCarlos Maiolino <[email protected]>2024-04-21 13:52:26 +0200
commit47b7016ed5ac6dd8efc041060d62e632e937a6d2 (patch)
tree2540760186b400288565c2d2f67dd3c3e93bcfe0 /stale/make_patchlist.sh
Initial commit
Diffstat (limited to 'stale/make_patchlist.sh')
-rwxr-xr-xstale/make_patchlist.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/stale/make_patchlist.sh b/stale/make_patchlist.sh
new file mode 100755
index 0000000..3168b9f
--- /dev/null
+++ b/stale/make_patchlist.sh
@@ -0,0 +1,63 @@
+#!/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