/
missing-pull.sh
executable file
·66 lines (54 loc) · 1.55 KB
/
missing-pull.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
#!/bin/bash
#
# Pull missing class names from {list_in}
# into 'src' tree file targets
#
# Copy written target file path names to {list_out}
# (git adds)
gwt_dir=~/src/google-web-toolkit
dev_dir=${gwt_dir}/trunk
list_in="missing.txt"
list_out="missing-pull.txt"
for name in $(egrep -v '^#' ${list_in} )
do
echo ${name}
for src in $(find ${dev_dir} -type f -name "${name}.java")
do
tgt=$(echo $src | sed 's%.*/com/google/%src/com/google/%')
if 2>/dev/null cp -p $src $tgt
then
if ! git add ${tgt}
then
echo "Warning, 'git add ${tgt}' failed"
fi
echo ${name} ${src}
echo ${tgt} >> ${list_out}
else
tgtd=$(dirname ${tgt})
if [ ! -d ${tgtd} ]
then
if mkdir -p ${tgtd}
then
if cp -p $src $tgt
then
if ! git add ${tgt}
then
echo "Warning, 'git add ${tgt}' failed"
fi
echo ${name} ${src}
echo ${tgt} >> ${list_out}
else
echo "Failure in 'cp $src $tgt'"
exit 1
fi
else
echo "Failure in 'mkdir -p $tgtd'"
exit 1
fi
else
echo "Warning, failure in 'cp $src $tgt'"
fi
fi
done
done
exit 0