summaryrefslogtreecommitdiff
path: root/stale/hooks.sh
blob: d8add4267f901bf5564929979fb5d6659e9ce041 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash

email=$1
patch=/tmp/$$.patch
tempfile=/tmp/item_menu.$$
sources=~/pristine/



clear_repo(){
	dialog --clear --yesno \
	" Wanna reset the git tree?" 0 0

	if [ $? -eq 0 ]; then
		git reset --hard
	fi
}

diff_patch(){

	dialog --clear --yesno --yes-label "git diff" --no-label "difftool" \
	"Choose DIFF format:" 0 0

	if [ $? -eq 0 ]; then
		git diff
	else
		git difftool
	fi

}

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
#cat $email | formail -I "" | awk '/^---/{p=1}p' > /tmp/patch.patch
apply_patch
clear_env