diff --git a/src/bin/create_ssh_config.sh b/src/bin/create_ssh_config.sh index cad2543..6170eda 100755 --- a/src/bin/create_ssh_config.sh +++ b/src/bin/create_ssh_config.sh @@ -13,6 +13,10 @@ REPOSITORY="$1"; JUMP_PROXY="$2"; +if [ "${REPOSITORY}" == "--help" ]; then + echo "$0 []"; + exit; +fi; # below are only to skip error BRANCH="-" diff --git a/src/bin/git_sync.sh b/src/bin/git_sync.sh index 6e22e52..fd5c563 100755 --- a/src/bin/git_sync.sh +++ b/src/bin/git_sync.sh @@ -7,6 +7,10 @@ REPOSITORY="$1"; BRANCH="$2"; REMOTE_NAME="$3"; +if [ "${REPOSITORY}" == "--help" ]; then + echo "$0 []"; + exit; +fi; if [ -z "${REMOTE_NAME}" ]; then REMOTE_NAME="origin" fi; diff --git a/src/bin/new_clone.sh b/src/bin/new_clone.sh index 9d92f82..04d2e15 100755 --- a/src/bin/new_clone.sh +++ b/src/bin/new_clone.sh @@ -11,6 +11,10 @@ BRANCH="$2"; REMOTE_HOST="$3"; REPOSITORY_FOLDER="$4" REMOTE_NAME="$5"; +if [ "${REPOSITORY}" == "--help" ]; then + echo "$0 [] [] []"; + exit; +fi; if [ -z "${REMOTE_NAME}" ]; then REMOTE_NAME="origin" fi; @@ -22,15 +26,6 @@ if [ -z "${REPOSITORY}" ]; then echo "[!] Must set a repository path"; error=1; fi; -# if remote host is empty try to set from repository -if [ -z "${REMOTE_HOST}" ]; then - if [[ "${REPOSITORY}" == *":"* ]]; then - REMOTE_HOST=$(echo "${REPOSITORY}" | cut -d ":" -f 1); - else - echo "[!] Must set a repository path with remote host for the repository"; - error=1; - fi; -fi; # if we have an ":" in the repository, split by it and replace it with the remote host if [[ "${REPOSITORY}" == *":"* ]]; then REPOSITORY=$(echo "${REPOSITORY}" | cut -d ":" -f 2); @@ -41,14 +36,18 @@ if [ -z "${REPOSITORY_FOLDER}" ]; then else GIT_REPOSITORY_NAME="${REPOSITORY_FOLDER}"; fi; +# set remote host if not set to the ssh config name +if [ -z "${REMOTE_HOST}" ]; then + REMOTE_HOST="${GIT_REPOSITORY_NAME}"; +fi; if [ $error -eq 1 ]; then exit; fi; error=0 echo "* Validate SSH PEM Key exist and SSH config"; -if ! grep "Host ${GIT_REPOSITORY_NAME}" "${GIT_WEBHOOK_BASE_FOLDER}"/.ssh/config; then - echo "[!] ssh config entry for Host ${GIT_REPOSITORY_NAME} is missing"; +if ! grep "Host ${REMOTE_HOST}" "${GIT_WEBHOOK_BASE_FOLDER}"/.ssh/config; then + echo "[!] ssh config entry for Host ${REMOTE_HOST} is missing"; error=1; else # make sure the identiy file is there diff --git a/src/bin/switch_branch.sh b/src/bin/switch_branch.sh index 2782ae2..2aed3b8 100755 --- a/src/bin/switch_branch.sh +++ b/src/bin/switch_branch.sh @@ -8,6 +8,10 @@ REPOSITORY="$1"; BRANCH="$2"; REMOTE_NAME="$3"; +if [ "${REPOSITORY}" == "--help" ]; then + echo "$0 []"; + exit; +fi; if [ -z "${REMOTE_NAME}" ]; then REMOTE_NAME="origin" fi;