blob: e1d3321d13c58bbb39a273bfc2d50279e428b29c (
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
58
59
60
61
|
#! /bin/sh
for arg in $@; do
option=`echo "'$arg'" | cut -d'=' -f1 | tr -d "'"`
value=`echo "'$arg'" | cut -d'=' -f2- | tr -d "'"`
if [ "$value" == "$option" ]; then value=""; fi
case "$option" in
-d|--git-dir) GIT_DIR=$value;;
-t|--tasks-dir) TASKS_DIR=$value;;
*) GIT_REMOTE=$arg;;
esac
done
GIT_DIR=${GIT_DIR:-$HOME/usr/git}
TASKS_DIR=${TASKS_DIR:-$GIT_DIR/templates/ruby-gem/tasks}
DIFF_OPTS=${DIFF_OPTS:--y --suppress-common-lines}
RESET="\033[0m"
RED="\033[0;31m"
GREEN="\033[0;32m"
BROWN="\033[0;33m"
PURPLE="\033[0;35m"
CYAN="\033[0;36m"
YELLOW="\033[1;33m"
function update() {
echo -e "\n${BROWN}${1}${RESET} : ${YELLOW}${2} ${PURPLE}${3}${RESET} differs ..."
diff ${DIFF_OPTS} ${3} ${2}
read -p " update it? [yN]" RET
if [ "${RET}" = "Y" -o "${RET}" = "y" ]; then
cp ${2} ${3}
fi
}
function copy() {
echo -e "\n${BROWN}${1}${RESET} : ${PURPLE}${3}${RESET} does not exists"
read -p " create it? [yN]" RET
if [ "${RET}" = "Y" -o "${RET}" = "y" ]; then
cp ${2} ${3}
fi
}
echo -e "task dir:${YELLOW}${TASKS_DIR}${RESET}"
for gitdir in ${GIT_DIR}; do
echo -e "enter ${BROWN}${gitdir}${RESET}" && cd ${gitdir} || return 1
for dir in $(ls -1); do
[ -d ${dir} ] && [ -e ${dir}/tasks/gem.rake ] || continue
# SEARCH REMOTE
echo -e " enter ${BROWN}${dir}${RESET}" && cd $dir || exit 1
for task_file in ${TASKS_DIR}/*; do
dest="./tasks/${task_file##*/}"
if [ -e $dest ]; then
cmp -s ${task_file} ${dest} || update ${dir} ${task_file} ${dest}
else
copy ${dir} ${task_file} ${dest}
fi
done
echo -e " leave ${BROWN}${dir}${RESET}\n" && cd .. || exit 1
done
echo -e "leave ${BROWN}${gitdir}${RESET}"
done
|