From 1398c20f4b43d5924946eef56aaba8dc14c0bddb Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Fri, 18 Dec 2020 18:47:17 -0500 Subject: [PATCH] use https module for initial clone/build --- bin/jvc_common | 13 +++++++++++-- bin/use_https_submodule | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) create mode 100755 bin/use_https_submodule diff --git a/bin/jvc_common b/bin/jvc_common index 2aad1cb..33fc3e5 100755 --- a/bin/jvc_common +++ b/bin/jvc_common @@ -63,8 +63,17 @@ if [[ -z "${JVC_JAR}" ]] ; then # Build and install utility library pushd "${JVC_DIR}"/utils/cobbzilla-utils || die "Error changing directories to ${JVC_DIR}/utils/cobbzilla-utils" - mvn -DskipTests=true clean install || die "Error building cobbzilla-utils library" - popd || die "popd error" + if [[ -z "$(find target -type f -name "*.jar")" ]] ; then + if [[ -z "$(find . -type f)" ]] ; then + cd ../.. && \ + ./bin/use_https_submodule && \ + git submodule update --init --recursive && \ + cd - \ + || die "Error updating git submodule" + fi + mvn -DskipTests=true clean install || die "Error building cobbzilla-utils library" + popd || die "popd error" + fi # Build jvc uberjar pushd "${JVC_DIR}" || die "Error changing directories to ${JVC_DIR}" diff --git a/bin/use_https_submodule b/bin/use_https_submodule new file mode 100755 index 0000000..369cdde --- /dev/null +++ b/bin/use_https_submodule @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Update .gitmodules file to use HTTPS URLs instead of SSH URLs for git submodules +# +SCRIPT_DIR="$(cd "$(dirname "${0}")" && pwd)" +GIT_MODS="${SCRIPT_DIR}/../.gitmodules" +GIT_TEMP_FILE="$(mktemp "${GIT_MODS}.XXXXXXX")" +CHANGED_MARKER="${GIT_TEMP_FILE}.use" +cat "${GIT_MODS}" | while read -r line; do + if [[ $(echo "${line}" | grep -c 'url = ') -gt 0 && $(echo "${line}" | grep -c 'git@git') -gt 0 ]]; then + REPO="$(echo "${line}" | awk -F ':' '{print $2}')" + echo "url = https://git.bubblev.org/${REPO}" | tee -a "${GIT_TEMP_FILE}" + touch "${CHANGED_MARKER}" + else + echo "${line}" | tee -a "${GIT_TEMP_FILE}" + fi +done + +if [[ -f "${CHANGED_MARKER}" ]]; then + cd "${SCRIPT_DIR}/.." && \ + git update-index --assume-unchanged "$(basename "${GIT_MODS}")" && \ + mv "${GIT_TEMP_FILE}" "${GIT_MODS}" || \ + echo "$0: error updating file: ${GIT_MODS}" +fi +rm -f "${CHANGED_MARKER}"