mirror of
https://github.com/flynx/git-utils.git
synced 2025-10-28 10:40:08 +00:00
Compare commits
2 Commits
f7793c80d4
...
be5055cd4d
| Author | SHA1 | Date | |
|---|---|---|---|
| be5055cd4d | |||
| 483f62db83 |
14
README.md
14
README.md
@ -1,2 +1,14 @@
|
|||||||
# git-utlis
|
# git-utlis
|
||||||
git utilities
|
|
||||||
|
This package provides a set of git _meta-porcelain_ commands to manage
|
||||||
|
a work tree with multiple git repositories.
|
||||||
|
|
||||||
|
Provided commands:
|
||||||
|
- `git listall`
|
||||||
|
List repositories in tree.
|
||||||
|
- `git cloneall FILE`
|
||||||
|
Clone all repositories in file
|
||||||
|
- `git pullall`
|
||||||
|
Pull changes for all repositories in tree
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -12,12 +12,12 @@ while true ; do
|
|||||||
echo
|
echo
|
||||||
echo "Repository list can be constructed from an existing set of"
|
echo "Repository list can be constructed from an existing set of"
|
||||||
echo "repositories via:"
|
echo "repositories via:"
|
||||||
echo " $ git remotes > reposiotry.lst"
|
echo " $ git listall -o > reposiotry.lst"
|
||||||
echo "or recursively:"
|
echo "or recursively:"
|
||||||
echo " $ git remotes -r > reposiotry.lst"
|
echo " $ git listall -o -r > reposiotry.lst"
|
||||||
echo
|
echo
|
||||||
echo "The repository list is a text file with each line consisting"
|
echo "The repository list is a text file with each line consisting"
|
||||||
echo "of a space-separated path and a remote url (as supported by"
|
echo "of a \"=\"-separated path and a remote url (as supported by"
|
||||||
echo "git clone)."
|
echo "git clone)."
|
||||||
echo "The list file can also contain empty lines and supports shell"
|
echo "The list file can also contain empty lines and supports shell"
|
||||||
echo "comments (lines starting with \"#\")"
|
echo "comments (lines starting with \"#\")"
|
||||||
@ -56,11 +56,11 @@ for repo in ${LIST[@]} ; do
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS=$' ' \
|
IFS=$'=' \
|
||||||
repo=($repo)
|
repo=($repo)
|
||||||
|
|
||||||
# skip existing dirs...
|
# skip existing dirs or local repos...
|
||||||
if [ -e "${repo[0]}" ] ; then
|
if [ -e "${repo[0]}" ] || [ "${repo[1]}" = "origin" ] ; then
|
||||||
#echo "skipping: ${repo[0]}"
|
#echo "skipping: ${repo[0]}"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -9,7 +9,8 @@ while true ; do
|
|||||||
echo
|
echo
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " -h --help - print this message and exit"
|
echo " -h --help - print this message and exit"
|
||||||
echo " -r --recursive - pull directories recursively"
|
echo " -r --recursive - list directories recursively"
|
||||||
|
echo " -o --origin - also print origin url"
|
||||||
echo
|
echo
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
@ -19,6 +20,11 @@ while true ; do
|
|||||||
shift
|
shift
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
|
-o|--origin)
|
||||||
|
ORIGIN=1
|
||||||
|
shift
|
||||||
|
continue
|
||||||
|
;;
|
||||||
|
|
||||||
-*|--*)
|
-*|--*)
|
||||||
echo "Error: unknown option: \"$1\"" >&2
|
echo "Error: unknown option: \"$1\"" >&2
|
||||||
@ -36,14 +42,25 @@ TARGET_PATH=${TARGET_PATH:=.}
|
|||||||
cd "$TARGET_PATH"
|
cd "$TARGET_PATH"
|
||||||
|
|
||||||
if [ $RECURSIVE ] ; then
|
if [ $RECURSIVE ] ; then
|
||||||
DIRS=($(find . -name .git | sort))
|
IFS=$'\n' \
|
||||||
|
DIRS=($(find . -name .git | sort))
|
||||||
else
|
else
|
||||||
DIRS=(./*/.git)
|
IFS=$'\n' \
|
||||||
|
DIRS=(./*/.git)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# XXX handle local repos...
|
||||||
|
getOrigin(){
|
||||||
|
if ! [ -z $ORIGIN ] ; then
|
||||||
|
cd "$1"
|
||||||
|
echo "=`git ls-remote --get-url origin`"
|
||||||
|
cd "$wd"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# inside a repo...
|
# inside a repo...
|
||||||
if [ -d ./.git ] ; then
|
if [ -d ./.git ] ; then
|
||||||
echo .
|
echo ".`getOrigin .`"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -51,7 +68,7 @@ fi
|
|||||||
wd=$(pwd)
|
wd=$(pwd)
|
||||||
for dir in ${DIRS[@]} ; do
|
for dir in ${DIRS[@]} ; do
|
||||||
dir=${dir%.git}
|
dir=${dir%.git}
|
||||||
echo $dir
|
echo "$dir`getOrigin "$dir"`"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,72 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
while true ; do
|
|
||||||
case $1 in
|
|
||||||
-h|--help)
|
|
||||||
echo "Usage: $(basename "$0") [OPTIONS] [PATH]"
|
|
||||||
echo
|
|
||||||
echo "Print origins of 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=-r
|
|
||||||
shift
|
|
||||||
continue
|
|
||||||
;;
|
|
||||||
|
|
||||||
-*|--*)
|
|
||||||
echo "Error: unknown option: \"$1\"" >&2
|
|
||||||
exit
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
TARGET_PATH=$1
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
TARGET_PATH=${TARGET_PATH:=.}
|
|
||||||
cd "$TARGET_PATH"
|
|
||||||
|
|
||||||
DIRS=($(git listall ${RECURSIVE}))
|
|
||||||
|
|
||||||
getOrigin(){
|
|
||||||
cd "$1"
|
|
||||||
git ls-remote --get-url origin
|
|
||||||
cd "$wd"
|
|
||||||
}
|
|
||||||
|
|
||||||
# inside a repo...
|
|
||||||
if [ -d ./.git ] ; then
|
|
||||||
echo ". `getOrigin .`"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# no matches...
|
|
||||||
if [[ $DIRS =~ \* ]] ; then
|
|
||||||
echo "no repos found." >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# do the update...
|
|
||||||
wd=$(pwd)
|
|
||||||
for dir in ${DIRS[@]} ; do
|
|
||||||
dir=${dir%.git}
|
|
||||||
echo "$dir `getOrigin "$dir"`"
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
# vim:set sw=4 ts=4 :
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user