diff options
Diffstat (limited to 'bin/mutt_hooks.sh')
| -rwxr-xr-x | bin/mutt_hooks.sh | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/bin/mutt_hooks.sh b/bin/mutt_hooks.sh new file mode 100755 index 0000000..36ecbf6 --- /dev/null +++ b/bin/mutt_hooks.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +email=$1 +patch=/tmp/$$.patch +tempfile=/tmp/item_menu.$$ +KERNEL_SOURCE=/home/cmaiolin/Source/kernel/linux.pristine/ + + + +clear_repo(){ + dialog --clear --yesno \ + " Wanna reset the git tree?" 0 0 + + if [ $? -eq 0 ]; then + git reset --hard + fi +} + +diff_patch(){ + +UPSTREAM_PATCH=/tmp/upstream.patch +UPSTREAM_COMMIT=/tmp/upstream.commit + + #get commit from message + cat $1 | grep "^commit"| awk '{for (I=1;I<=NF;I++) if ($I == "commit") {print $(I+1)};}' | sed 's/)//' > $UPSTREAM_COMMIT + + # commit probably cherry-picked + if [ -z `cat $UPSTREAM_COMMIT` ]; then + + cat $1 | grep "commit"| awk '{for (I=1;I<=NF;I++) if ($I == "commit") {print $(I+1)};}' | sed 's/)//' > $UPSTREAM_COMMIT + + fi + #COMMIT=`cat $1 | grep "commit"| awk '{for (I=1;I<=NF;I++) if ($I == "commit") {print $(I+1)};}' | awk -F'|' '{print $1}' | sed 's/)//'` + + COMMIT=`cat $UPSTREAM_COMMIT |head -1` + echo $COMMIT + #Extract upstream patch + echo "Entering source" + cd $KERNEL_SOURCE + echo "Extracting patch" + git format-patch --stdout -1 $COMMIT > $UPSTREAM_PATCH + echo $UPSTREAM_PATCH + cd - + echo "STARTING DIFF" + vimdiff $patch $UPSTREAM_PATCH + + rm $UPSTREAM_PATCH $UPSTREAM_COMMIT +} + +apply_patch(){ + repolist=$(ls $sources | awk '{print $1,$1}') + + 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` + + echo $repo + cd $sources/$repo + git apply $patch + #diff_patch + clear_repo +} + +clear_env(){ + rm -rf $tempfile + rm -rf $patch +} + +###main + +cat $email | formail -I "" > $patch +diff_patch $patch +#cat $email | formail -I "" | awk '/^---/{p=1}p' > /tmp/patch.patch +rm $patch +#apply_patch +#clear_env |
