mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 03:53:32 +01:00
100 lines
1.4 KiB
Bash
100 lines
1.4 KiB
Bash
#!/bin/sh
|
|
|
|
log()
|
|
{
|
|
echo $@
|
|
}
|
|
|
|
err()
|
|
{
|
|
log $@
|
|
}
|
|
|
|
fatal()
|
|
{
|
|
err $@
|
|
exit 1
|
|
}
|
|
|
|
marker()
|
|
{
|
|
log "# ============= $@"
|
|
}
|
|
|
|
config()
|
|
{
|
|
# guess pdir
|
|
pdir=`pwd`
|
|
while [ `cat $pdir/CVS/Repository 2>/dev/null` != proj ]; do
|
|
[ "$pdir" = / ] && fatal "didn't find \"proj\" in directory components"
|
|
pdir=`dirname $pdir`
|
|
done
|
|
pdirs=`(cd $pdir; ls -d */.git | sed 's%/.git%%')`
|
|
}
|
|
|
|
# ------------- commands
|
|
run()
|
|
{(
|
|
local d
|
|
local cmd=$1
|
|
shift
|
|
config
|
|
cd $pdir
|
|
|
|
set -e
|
|
for d in $pdirs; do
|
|
marker $d
|
|
git -C $d $cmd "$@"
|
|
done
|
|
)}
|
|
|
|
clone()
|
|
{(
|
|
local p
|
|
config
|
|
cd $pdir
|
|
local id=$PGIT_CLONE_FROM_USER
|
|
local projects="$PGIT_CLONE_PROJECTS"
|
|
[ "$id" ] || id=`whoami`
|
|
if [ -z "$projects" ]; then
|
|
projects=`$SSH git.jannet.de /opt/ytools/bin/git-srv-admin.sh -u $id -j list-personal-projects`
|
|
[ "$?" != 0 ] && exit 1
|
|
fi
|
|
set -e
|
|
for p in $projects; do
|
|
[ -d $p ] && {
|
|
marker "skipping existing $p"
|
|
continue
|
|
}
|
|
marker "cloning $p"
|
|
git clone ssh://$id@git.jannet.de/srv/git/$id/proj/$p
|
|
git -C $p submodule init || fatal git submodule init failed in `pwd`
|
|
git -C $p submodule update || fatal git submodule update failed in `pwd`
|
|
done
|
|
)}
|
|
|
|
diff()
|
|
{(
|
|
local d
|
|
config
|
|
cd $pdir
|
|
for d in $pdirs; do
|
|
marker $d
|
|
git -C $d diff --src-prefix=a/$d/ --dst-prefix=b/$d/ "$@"
|
|
done
|
|
)}
|
|
|
|
SSH=ssh
|
|
[ "$GIT_SSH" ] && SSH=$GIT_SSH
|
|
|
|
cmd=$1
|
|
shift
|
|
case $cmd in
|
|
clone|diff)
|
|
$cmd "$@"
|
|
;;
|
|
*)
|
|
run $cmd "$@"
|
|
;;
|
|
esac
|
|
|