Add help and fix problem with Host name set for new clone

The host name ise set as ssh config entry with ssh key, so we use the short name set for the remote host name
This commit is contained in:
2025-11-17 11:12:54 +09:00
parent 329f3abb6b
commit 08e9ff9e67
4 changed files with 22 additions and 11 deletions

View File

@@ -13,6 +13,10 @@
REPOSITORY="$1";
JUMP_PROXY="$2";
if [ "${REPOSITORY}" == "--help" ]; then
echo "$0 <Repo.git> [<Jump Proxy>]";
exit;
fi;
# below are only to skip error
BRANCH="-"

View File

@@ -7,6 +7,10 @@
REPOSITORY="$1";
BRANCH="$2";
REMOTE_NAME="$3";
if [ "${REPOSITORY}" == "--help" ]; then
echo "$0 <Repo.git> <branch> [<remote name, defaults to origin>]";
exit;
fi;
if [ -z "${REMOTE_NAME}" ]; then
REMOTE_NAME="origin"
fi;

View File

@@ -11,6 +11,10 @@ BRANCH="$2";
REMOTE_HOST="$3";
REPOSITORY_FOLDER="$4"
REMOTE_NAME="$5";
if [ "${REPOSITORY}" == "--help" ]; then
echo "$0 <Repo.git> <branch> [<override host>] [<target folder>] [<remote name, defaults to origin>]";
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

View File

@@ -8,6 +8,10 @@
REPOSITORY="$1";
BRANCH="$2";
REMOTE_NAME="$3";
if [ "${REPOSITORY}" == "--help" ]; then
echo "$0 <Repo.git> <branch> [<remote name, defaults to origin>]";
exit;
fi;
if [ -z "${REMOTE_NAME}" ]; then
REMOTE_NAME="origin"
fi;