bin-utils/gitremotediff.sh

35 lines
706 B
Bash
Raw Normal View History

2015-05-30 16:42:42 +00:00
#!/bin/bash
# find diff between git working copy and remote
# directory containing working copies
DIR_ROOT=$1
if [[ ! $DIR_ROOT ]] || [[ ! -d $DIR_ROOT ]]; then
echo "Usage: $0 root_dir"
exit 1
fi
# remember work dir
ORIG_DIR=$PWD
# search working copies
for GITDIR in $( find $DIR_ROOT -name .git -type d ); do
WORKCOPY=${GITDIR%/.git}
cd $WORKCOPY
# tester s'il y a un repo remote
if [ -n "$( git remote)" ]; then
# fetch remote
git fetch -q
# fichiers differents
GITREMOTEDIFF=$( git diff --name-status remotes/origin/master )
if [ -n "$GITREMOTEDIFF" ];then
echo "$WORKCOPY not synchronised with remote"
echo "$GITREMOTEDIFF"
fi
fi
# restore work dir
cd $ORIG_DIR
done