mirror of
https://github.com/flynx/git-utils.git
synced 2025-12-25 04:42:05 +00:00
59 lines
825 B
Bash
Executable File
59 lines
825 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
while true ; do
|
|
case $1 in
|
|
-h|--help)
|
|
echo "Usage: $(basename "$0") [OPTIONS] [PATH]"
|
|
echo
|
|
echo "List all repositories in PATH."
|
|
echo
|
|
echo "Options:"
|
|
echo " -h --help - print this message and exit"
|
|
echo " -r --recursive - pull directories recursively"
|
|
echo
|
|
exit
|
|
;;
|
|
|
|
-r|--recursive)
|
|
RECURSIVE=1
|
|
shift
|
|
continue
|
|
;;
|
|
|
|
-*|--*)
|
|
echo "Error: unknown option: \"$1\"" >&2
|
|
exit
|
|
;;
|
|
*)
|
|
TARGET_PATH=$1
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
TARGET_PATH=${TARGET_PATH:=.}
|
|
cd "$TARGET_PATH"
|
|
|
|
if [ $RECURSIVE ] ; then
|
|
DIRS=($(find . -name .git | sort))
|
|
else
|
|
DIRS=(./*/.git)
|
|
fi
|
|
|
|
# inside a repo...
|
|
if [ -d ./.git ] ; then
|
|
echo .
|
|
exit 0
|
|
fi
|
|
|
|
# do the update...
|
|
wd=$(pwd)
|
|
for dir in ${DIRS[@]} ; do
|
|
dir=${dir%.git}
|
|
echo $dir
|
|
done
|
|
|
|
|
|
# vim:set sw=4 ts=4 :
|