ruby/tool/git-refresh

37 строки
762 B
Plaintext
Исходник Обычный вид История

#!/bin/sh
set -e
quiet=
branch=
until [ $# = 0 ]; do
case "$1" in
--) shift; break;;
-C|--directory) shift; cd "$1";;
-C*) cd `expr "$1" : '-C\(.*\)'`;;
--directory=*) cd `expr "$1" : '[^=]*=\(.*\)'`;;
-q) quiet=1;;
-b|--branch) shift; branch="$1";;
-b*) branch=`expr "$1" : '-b\(.*\)'`;;
--branch=*) branch=`expr "$1" : '[^=]*=\(.*\)'`;;
-*) echo "unknown option: $1" 1>&2; exit 1;;
*) break;;
esac
shift
done
url="$1"
dir="$2"
shift 2
if [ -d "$dir" ]; then
echo updating `expr "$dir" : '*/\(.*\)'` ...
[ $quiet ] || set -x
cd "$dir"
git fetch "$@"
exec git checkout ${branch:+"$branch"} "$@"
else
echo retrieving `expr "$dir" : '*/\(.*\)'` ...
[ $quiet ] || set -x
exec git clone "$url" "$dir" "$@"
fi