mirror of
https://github.com/flynx/git-utils.git
synced 2025-12-25 21:02:05 +00:00
Compare commits
No commits in common. "be5055cd4d50a33b9746b441d172a5b29405d4f4" and "f7793c80d45c7f30efaa05f318f2bfd48cbdebc6" have entirely different histories.
be5055cd4d
...
f7793c80d4
14
README.md
14
README.md
@ -1,14 +1,2 @@
|
|||||||
# 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 listall -o > reposiotry.lst"
|
echo " $ git remotes > reposiotry.lst"
|
||||||
echo "or recursively:"
|
echo "or recursively:"
|
||||||
echo " $ git listall -o -r > reposiotry.lst"
|
echo " $ git remotes -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 \"=\"-separated path and a remote url (as supported by"
|
echo "of a space-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 or local repos...
|
# skip existing dirs...
|
||||||
if [ -e "${repo[0]}" ] || [ "${repo[1]}" = "origin" ] ; then
|
if [ -e "${repo[0]}" ] ; then
|
||||||
#echo "skipping: ${repo[0]}"
|
#echo "skipping: ${repo[0]}"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -9,8 +9,7 @@ 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 - list directories recursively"
|
echo " -r --recursive - pull directories recursively"
|
||||||
echo " -o --origin - also print origin url"
|
|
||||||
echo
|
echo
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
@ -20,11 +19,6 @@ 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
|
||||||
@ -42,25 +36,14 @@ TARGET_PATH=${TARGET_PATH:=.}
|
|||||||
cd "$TARGET_PATH"
|
cd "$TARGET_PATH"
|
||||||
|
|
||||||
if [ $RECURSIVE ] ; then
|
if [ $RECURSIVE ] ; then
|
||||||
IFS=$'\n' \
|
|
||||||
DIRS=($(find . -name .git | sort))
|
DIRS=($(find . -name .git | sort))
|
||||||
else
|
else
|
||||||
IFS=$'\n' \
|
|
||||||
DIRS=(./*/.git)
|
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 ".`getOrigin .`"
|
echo .
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -68,7 +51,7 @@ fi
|
|||||||
wd=$(pwd)
|
wd=$(pwd)
|
||||||
for dir in ${DIRS[@]} ; do
|
for dir in ${DIRS[@]} ; do
|
||||||
dir=${dir%.git}
|
dir=${dir%.git}
|
||||||
echo "$dir`getOrigin "$dir"`"
|
echo $dir
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
72
bin/git-origins
Executable file
72
bin/git-origins
Executable file
@ -0,0 +1,72 @@
|
|||||||
|
#!/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