From d6038a4165215dcc9d9563b6aa1ed03ee647e912 Mon Sep 17 00:00:00 2001 From: Meutel Date: Thu, 6 Sep 2018 15:04:46 +0200 Subject: [PATCH] Script log nouveaux commits git --- git_check.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 git_check.sh diff --git a/git_check.sh b/git_check.sh new file mode 100755 index 0000000..bb80beb --- /dev/null +++ b/git_check.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +REPO_PATH="$1" +LOCAL_BRANCH="$2" +REMOTE="$3" +REMOTE_BRANCH="$4" + +LOCAL_BRANCH=${LOCAL_BRANCH:="master"} +REMOTE=${REMOTE:="origin"} +REMOTE_BRANCH=${REMOTE_BRANCH:=$LOCAL_BRANCH} + +usage() { + echo "git_check.sh repo [local_branch [remote [remote_branch]]]" > /dev/stderr + echo " repo: repository path" > /dev/stderr + echo " local_branch: name of local branch" > /dev/stderr + echo " remote: name of remote" > /dev/stderr + echo " remote_branch: name of remote branch" > /dev/stderr +} + +check_vars() +{ + if [ -z "$REPO_PATH" ] + then + echo "Missing repo path" > /dev/stderr + usage + exit 1 + fi + if [ ! -d $REPO_PATH ] + then + echo "$REPO_PATH should be a directory" > /dev/stderr + usage + exit 2 + fi +} + +check_vars + +git -C "$REPO_PATH" fetch "$REMOTE" +git -C "$REPO_PATH" log "$LOCAL_BRANCH..${REMOTE}/${REMOTE_BRANCH}"