forked from Electron-Cash/Electron-Cash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy_back_changes.sh
executable file
·112 lines (93 loc) · 2.16 KB
/
copy_back_changes.sh
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
. ./common.sh
if [ ! -d iOS ]; then
echo "Error: No iOS directory"
exit 1
fi
DIFF="diff"
if which -s gdiff; then
DIFF="gdiff --color=always"
fi
projdir="iOS/app"
projdir_top="iOS/"
pushd . > /dev/null
cd $projdir
a=`find ${compact_name}/ -type f -depth 1 -name \*.py -print`
b=`find ${compact_name}/electroncash_gui -type f -name \*.py -print`
c=`find ${compact_name}/electroncash -type f -name \*.py -print`
popd > /dev/null
pushd . > /dev/null
cd $projdir_top
res=`find Resources -type f -print`
ccode=`find CustomCode -type f -print`
popd > /dev/null
allYes=0
ct=0
skipped=0
function doIt() {
f1=$1
f2=$2
dstInfo=$3
if [ -e "$f1" ] && $DIFF -q $f1 $f2 > /dev/null 2>&1; then
true
else
while true; do
answer=""
prompt="$f1 changed -- copy back to $dstInfo ? ([y]es/[n]/[a]ll/[d]iff)"
if [ "$allYes" != "1" ]; then
echo ""
echo "$prompt"
fi
if [ "$allYes" == "0" ]; then
read answer
fi
if [ "$answer" == "d" ]; then
$DIFF -u $f1 $f2 | less -r
echo ""
continue
fi
break
done
if [ "$answer" == "a" ]; then
allYes=1
fi
if [ "$answer" == "y" -o "$allYes" == "1" ]; then
cp -v $f2 $f1
let ct++
else
let skipped++
fi
fi
}
for file in $a $b; do
f1="${file}"
f2="${projdir}/${file}"
doIt "$f1" "$f2" "${compact_name}/"
done
for f in $c; do
file=`echo $f | cut -f 3- -d '/'`
f1="../electroncash/${file}"
f2="${projdir}/${f}"
doIt "$f1" "$f2" "../electroncash/"
done
for file in $res; do
f1="${file}"
f2="${projdir_top}/${file}"
doIt "$f1" "$f2" "Resources/"
done
for file in $ccode; do
f1="${file}"
f2="${projdir_top}/${file}"
doIt "$f1" "$f2" "CustomCode/"
done
echo ""
if ((ct>0)); then
echo "Copied back $ct changed file(s)"
fi
if ((skipped>0)); then
echo "Skipped $skipped"
fi
if [ $skipped == 0 -a $ct == 0 ]; then
echo "No changes detected in iOS/"
fi
echo "Done."