diff options
author | Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr> | 2017-03-29 18:00:06 +0200 |
---|---|---|
committer | Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr> | 2017-03-30 18:58:33 +0200 |
commit | 3137acdd5a45285dab9903f9d41560c63eca8523 (patch) | |
tree | 38bd8525a9e214d848a73fc40e81ddb182cf91b6 /tools/bin/gitStatus.sh | |
parent | 9b30fc10fb1cbebe651e5a107e8ca5b24de54675 (diff) |
first commit
Change-Id: I8412b8e7d966c2fbc508b537fd9a9bbcfc628ca8
Signed-off-by: Angelo Mantellini (manangel) <angelo.mantellini@irt-systemx.fr>
Diffstat (limited to 'tools/bin/gitStatus.sh')
-rw-r--r-- | tools/bin/gitStatus.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/tools/bin/gitStatus.sh b/tools/bin/gitStatus.sh new file mode 100644 index 00000000..a586c644 --- /dev/null +++ b/tools/bin/gitStatus.sh @@ -0,0 +1,72 @@ +#!/bin/sh + +if [ $# -lt 5 ]; then + echo "ERROR incorrect number of parameters" + echo "Usage:" + echo " $0 <repo_name> <repo_directory> <origin> <remote_name> <remote_url>" + echo + echo "$0 check the values of the repo. Compare what git things with what we would like" + echo " repo_name - Name of the repo (cosmetic)" + echo " repo_directory - Directory where to find the git repo" + echo " origin - What origin should be set to" + echo " remote_name - The name of a remote to check" + echo " remote_url - What that remote should be set to" + exit 1 +fi + +REPO_NAME=$1 +REPO_DIR=$2 +ORIGIN=$3 +REMOTE_NAME=$4 +REMOTE_URL=$5 + +if [ ! -d $REPO_DIR ]; then + echo "ERROR running $0" + echo " Directory $REPO_DIR not found" + exit 1 +fi + +cd $REPO_DIR + +NEEDS_UPDATE=NO + +echo "###################################################################" +echo "# $REPO_NAME " + +# An origin of - means we should ignore the origin check +if [ $ORIGIN != - ]; then + ORIGIN_ACTUAL=`git config --get remote.origin.url` + if [ $ORIGIN_ACTUAL != $ORIGIN ]; then + echo "# WARNING: remote origin missmatch" + echo "# Expected $ORIGIN" + echo "# Found $ORIGIN_ACTUAL" + NEEDS_UPDATE=YES + fi +fi + +REMOTE_URL_ACTUAL=`git config --get remote.$REMOTE_NAME.url 2>/dev/null` + +if [ $? -ne 0 ]; then + echo "# WARNING remote $REMOTE_NAME does not exist" + echo "# Expected $REMOTE_NAME = $REMOTE_URL" + echo "# Found a remote called $REMOTE_NAME does not exist" + NEEDS_UPDATE=YES +else + if [ $REMOTE_URL_ACTUAL != $REMOTE_URL ]; then + echo "# WARNING remote $REMOTE_NAME missmatch" + echo "# Expected $REMOTE_NAME = $REMOTE_URL" + echo "# Found $REMOTE_NAME = $REMOTE_URL_ACTUAL" + NEEDS_UPDATE=YES + fi +fi + +if [ $NEEDS_UPDATE = NO ]; then + echo "# Up to date" + exit 0 +fi + +echo "#" +echo "# Your settings don't match the default settings for $REPO_NAME" +echo "# located at $REPO_DIR" + + |